﻿@using LanDBom.Models;
@using LanDBom.Resources
@{
    ViewBag.Title = "Application";
}
@section styles{
    <style>

        span {
            color: red
        }

        .JNSSS table tbody td:nth-child(2), .JNSSS table thead td:nth-child(1) {
            width: 50px;
        }
    </style>
}
<from>
    <fieldset class="boun">
        <legend></legend>
        <div class="row bian">
            <label class="col-sm-3 breadcrumb-item ">步骤一：申请单创建</label>
            <ul id="lisul" class="row col-sm-5">
                <li class="lisu">1</li>&rArr;
                <li class="lisu"></li>&rArr;
                <li class="lisu"></li>&rArr;
                <li class="lisu"></li>&rArr;
                <li class="lisu"></li>&rArr;
                <li class="lisu"></li>&rArr;
                <li class="lisu"></li>&rArr;
                <li class="lisu"></li>
            </ul>
            <div class="col-sm-4">
                <div class="anzhu" style="text-align:right">
                    <div class="col-2" style="display:none" id="divv_2"><button id="btnBaocun" class="btn_app_tj Yinchande" type="button" value="保存">保存</button></div>
                    <div class="col-2" style="display:none" id="divv_1"><button id="btnCreate" class="btn_app_tj" type="button" value="提交">提交</button></div>
                    <div class="col-2" style="display:none" id="divv_09"><button id="btnUpdate" type="button" value="修改">修改设计委托</button></div>
                    <div class="col-2" style="display:none" id="divv_4"><button id="btnBOHUI" type="button">驳回</button></div>
                    <div class="col-2" style="display:none" id="divv_8"><button id="btnWCXM" type="button">通过</button></div>
                    <div class="col-2" style="display:none" id="divv_6"><button id="WCSJ" type="button">递交</button></div>
                    <div class="col-2" style="display:none" id="divv_10"><button id="BBSJ" type="button">版本升级</button></div>
                    <div class="col-2" style="display:none" id="divv_5"><button id="btnWANC" type="button">完成设计</button></div>
                    <div class="col-2" id="divv_3"><button id="btnreste" type="button">返回</button></div>
                </div>
            </div>
        </div>
    </fieldset>
</from>
<div class="form-horizontal row">
    <div style="display:none" id="LIunji">@ViewBag.Shuai</div>
    <div class="Zhuyags">
        <div class="col-2 nav-item qh_div" id="divjibeng" style="background-color:#fff">@Resource.String48</div>
        <div class="col-2 nav-item qh_div" id="divbeizhu">@Resource.String49</div>
        <div class="col-2 nav-item qh_div" id="divtuzhi">@Resource.String50</div>
        <div class="col-2 nav-item qh_div" id="divweituo" style="display:none">@Resource.String51</div>
        <div class="col-2 nav-item qh_div" id="divSP_FP" style="display:none">分配/审核</div>
    </div>

    <div id="appp_id" style="display:none">@(Session["appp_id"])</div>
    <div id="appp_Sjzt" style="display:none">@(Session["name"])</div>

    <div class="col-12">
        <div id="div1" style="display:block; ">
            <fieldset class="boun">
                <legend class="len">@Resource.String52</legend>
                <table class="table-app" cellpadding="2" align="left">
                    <tbody>
                        <tr>
                            <td class="form-group"> <label for="CL_number" class=" control-label">@Resource.String793</label></td>
                            <td class="form-group">
                                <select class="form-control" id="SelZZ">
                                </select>
                            </td>
                            <td class="form-group"> <label for="CL_number" class=" control-label">项目负责人</label></td>
                            <td class="form-group">
                                <select class="form-control" id="XMfzr">
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="form-group">
                                <label for="CL_number" class=" control-label">@Resource.String53</label>
                            </td>
                            <td class="nav">
                                <input type="text" name="CLkjinne" value="" class="form-control" id="txtname" list="seleect_codeDE" />
                                &nbsp;
                                @Html.ActionLink(Resource.String54, "CUstom", new { Controller = "Custom", Action = "Custom" }, new { @class = "huns Yinchande" })
                                <datalist id="seleect_codeDE" class="form-control" style="display:none">
                                </datalist>
                            </td>
                            <td class="form-group">
                                <label for="danww" class="control-label">@Resource.String55</label>
                            </td>
                            <td><input type="text" class="form-control" id="txtdan" placeholder="名称" name="dan" readonly="readonly"></td>
                        </tr>
                        <tr style="display:none">
                            <td id="Ap_ren">
                                @if (MyAuthentication.IsLogin())
                                {
                                    @(MyAuthentication.GetUsers().DE_nae)
                                }
                            </td>
                            <td id="BIanhao"></td>
                            <td id="Faqiren"></td>
                        </tr>
                        <tr>
                            <td class="form-group">
                                <label for="CL_address" class=" control-label">@Resource.String56</label>

                            </td>
                            <td class="">
                                <input type="datetime" class="form-control" id="txtqishi" placeholder="发布日期" name="qishi" readonly="readonly">
                            </td>
                            <td class="form-group">
                                <label for="CL_phone" class=" control-label">@Resource.String57</label>

                            </td>
                            <td class="">
                                <input type="date" class="form-control" id="txtjeishu" placeholder="截止日期" name="jeishu">
                            </td>
                        </tr>
                        <tr>
                            <td class="form-group">
                                <label for="CL_email" class=" control-label">@Resource.String58</label>

                            </td>
                            <td class="">
                                <input type="text" class="form-control" id="txtxiangmu" placeholder="项目名称" name="xiangmu">
                            </td>
                            <td class="form-group">
                                <label for="CL_remarks" class=" control-label">@Resource.String59</label>
                            </td>
                            <td class="">
                                <input type="text" class="form-control" id="txtzhongduan" placeholder="终端客户" name="zhongduan" list="SH_ZDLH">
                                <datalist id="SH_ZDLH" class="form-control" style="display:none">
                                </datalist>
                            </td>
                        </tr>
                        <tr>
                            <td class="form-group">
                                <label for="CL_shipping_address" class=" control-label">@Resource.String60</label>

                            </td>
                            <td class="" id="divsho">
                                <input type="text" class="form-control" id="txtsho" placeholder="收货地址" name="shoH" list="SH_DZ">
                                <datalist id="SH_DZ" class="form-control" style="display:none">
                                </datalist>
                            </td>
                            <td class="form-group">
                                <label for="CL_distance" class=" control-label">@Resource.String61</label>

                            </td>
                            <td class="">
                                <input type="number" class="form-control" id="txtjuli" placeholder="距离" name="distance" min="0" max="100000">
                            </td>
                        </tr>
                        <tr>
                            <td class="form-group">
                                <label for="CL_shipping_address" class=" control-label">@Resource.String62</label>

                            </td>
                            <td class="">
                                <select name="Cname" class="form-control" id="txtxun">
                                    <option>--@Resource.String63--</option>
                                    <option value="降低成本">@Resource.String64</option>
                                    <option value="配合灵活性">@Resource.String65</option>
                                    <option value="质量改善">@Resource.String66</option>
                                    <option value="替代物料">@Resource.String67</option>
                                    <option value="快速响应">@Resource.String68</option>
                                    <option value="更快交期">@Resource.String69</option>
                                </select>
                            </td>
                            <td class="form-group">
                                <label for="CL_distance" class=" control-label">@Resource.String70</label>
                            </td>
                            <td class="">
                                <input type="text" name="CLkjinne" value="" class="form-control" id="txtfu" list="Loishud_sj" />
                                <datalist id="Loishud_sj" class="form-control" style="display:none">
                                </datalist>
                            </td>
                        </tr>
                        <tr>
                            <td class="form-group">
                                <label for="CL_email" class=" control-label">@Resource.String71</label>
                            </td>
                            <td class="">
                                <select class="form-control" id="txtleix" placeholder="项目类型" name="xiangmu">
                                    <option>--@Resource.String63--</option>
                                    <option value="委外">@Resource.String73</option>
                                    <option value="自制">@Resource.String74</option>
                                    <option value="套件">@Resource.String75</option>
                                    <option value="外购">@Resource.String76</option>
                                </select>
                            </td>
                            <td class="form-group">
                                <label for="CL_email" class=" control-label">@Resource.String77</label>
                            </td>
                            <td class="">
                                <select class="form-control" id="Selse" placeholder="设计委托" name="xiangmu">
                                    <option value="N">N</option>
                                    <option value="Y">@Resource.String78</option>
                                    <option value="S">@Resource.String79</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="form-group">
                                <label for="CL_email" class=" control-label">@Resource.String80</label>
                            </td>
                            <td class="">
                                <select class="form-control" id="hangye1" placeholder="行业大类" name="hangye1">
                                    <option>--@Resource.String48--</option>
                                    @foreach (var item in ViewBag.ic as List<IndustryCategory>)
                                    {
                                        <option value="@item.ic_id" id="CL_ID">@item.ic_name</option>
                                    }
                                </select>
                            </td>
                            <td class="form-group">
                                <label for="CL_email" class=" control-label">@Resource.String81</label>
                            </td>
                            <td class="">
                                <select class="form-control" id="hangye2" placeholder="行业小类" name="hangye2">
                                    <option>--@Resource.String63--</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="form-group">
                                <label for="CL_email" class=" control-label">@Resource.String82</label>
                            </td>
                            <td class="">
                                <input type="text" class="form-control" id="txtbaozuang" placeholder="包装物名称" name="zhongduan">
                            </td>
                            <td class="form-group">
                                <label for="" class=" control-label">项目价值(RMB)</label>
                            </td>
                            <td class="">
                                <input type="number" class="form-control" id="txtPrice" placeholder="项目价值" name="xiangmuPric">
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
        </div>
        @*项目备注*@
        <div id="div2" style="display:none">
            <div class="">
                <div id="bigbox1">
                    <fieldset class="boun" id="boun" style="height:150px">
                        <legend class="len">@Resource.String558</legend>
                        <div id="RZ_gwzr" class="beizhugun">

                        </div>
                    </fieldset>
                </div>
                <div>
                    <fieldset class="boun" id="boun2">
                        <legend class="len">@Resource.String560</legend>
                        <div class="row">
                            <div class="col-2">@Resource.String563</div>
                            <div class="col-8"><textarea id="RZ_xznr" class="col-10" style="height:100px"></textarea></div>
                        </div>
                        <div style="text-align:right">
                            <button id="RZ_tjrz" class="col-2">@Resource.String564</button>
                        </div>
                    </fieldset>
                </div>
                @*<div class="row">
                        <div class="col-3" id="CKSJBZ">@Resource.String559</div>
                        <div class="col-3" id="WCSJ">完成设计</div>
                    </div>*@
                <div>
                    <fieldset class="boun" id="boun3">
                        <legend class="len">@Resource.String565</legend>
                        <table style="width:100%;text-align:center" id="tab_wj">
                            <thead>
                                <tr style="background-color: #84acde">
                                    <td>@Resource.String566</td>
                                    <td>@Resource.String567</td>
                                    <td>@Resource.String568</td>
                                    <td>@Resource.String569</td>
                                    <td>上传</td>
                                    <td>删除</td>
                                </tr>
                            </thead>
                            <tbody id="logfuj">
                            </tbody>
                            <tfoot>
                                <tr>
                                    <td></td>
                                    <td></td>
                                    <td colspan="2"><input type="file" id="SC_FJ_Wj" multiple /></td>
                                    <td><a href="#" id="log_SCFJ">@Resource.String574</a></td>
                                </tr>
                            </tfoot>
                        </table>
                    </fieldset>
                </div>
            </div>
        </div>
        @*图纸备注*@
        <div id="div3" style="display:none">
            <fieldset class="boun">
                <legend class="len">@Resource.String84</legend>
                <div style="color:red;"><button class="xiaosd ">下载</button> </div>
                <div class="div_A JNSSS">
                    <table class="table tab" style="width:150%">
                        <thead style="text-align:center;">
                            <tr style="background-color: #6e95bc">
                                <td>@Resource.String85</td>
                                <td>@Resource.String86</td>
                                <td>@Resource.String241</td>
                                <td>@Resource.String87</td>
                                <td>行业大类</td>
                                <td>行业小类</td>
                                <td>包装类别</td>
                                <td>图纸类别</td>
                                <td>版本</td>
                                <td>@Resource.String88</td>
                                <td>@Resource.String1298</td>
                                <td>@Resource.String571</td>
                                <td>审核时间</td>
                                <td>审核说明</td>
                                <td>@Resource.String89</td>
                            </tr>
                        </thead>
                        <tbody id="div3__tb" style="height:400px">
                        </tbody>
                        <tfoot>
                            <tr>
                                <td>@Resource.String1299</td>
                                <td id="SJ_ZYS"></td>
                                <td></td>
                            </tr>
                        </tfoot>
                    </table>
                </div>

            </fieldset>
        </div>
        <div style="display:none" id="JNDKO">@(Session["JKO_ko"])</div>@*设计人员进入时判断是否启用驳回*@
        @*设计委托信息填写*@
        <div id="div4" style="display:none">
            <div class="">
                <fieldset class="boun">
                    <legend class="len">设计委托</legend>
                    <table class="sheji table">
                        <tbody>
                            <tr style="display:none"><td id="Derowid"></td></tr>
                            <tr style="display:none"><td id="ZhuathhskM"></td></tr>
                            <tr>
                                <td><span>*</span>@Resource.String638</td>
                                <td id="WT_sqrq"></td>
                                <td><span>*</span>@Resource.String639</td>
                                <td><input type="date" id="WT_yqrq" /></td>
                                <td>@Resource.String640</td>
                                <td id="WT_rwdh"></td>
                            </tr>
                            <tr>
                                <td><span>*</span>@Resource.String641</td>
                                <td><input type="text" id="WT_sqr" readonly /></td>
                                <td>@Resource.String642</td>
                                <td><input type="text" id="WT_sqshr" readonly /></td>
                                <td style="display:none"> <span>*</span>@Resource.String643</td>
                                <td style="display:none"><input type="number" id="WT_xmjz" /></td>
                            </tr>
                            <tr>
                                <td><span>*</span>@Resource.String644</td>
                                <td style="position:relative">
                                    <input type="text" id="WT_khmc" readonly />
                                </td>
                                <td><span>*</span>@Resource.String645</td>
                                <td><input type="text" id="WT_cpmc" readonly /></td>
                                <td>@Resource.String646</td>
                                <td>
                                    <select id="WT_rwdlx">
                                        <option value="null">----@Resource.String647----</option>
                                        <option value="图纸">-@Resource.String649</option>
                                        <option value="项目">-@Resource.String650</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td><span>*</span>@Resource.String652</td>
                                <td id="WT_sjlb">
                                    <input type="checkbox" value="结构" class="WT_sjlb_ch" name="WT_sjlb" />@Resource.String654
                                    <input type="checkbox" value="平面" class="WT_sjlb_ch" name="WT_sjlb" />@Resource.String656
                                    <input type="checkbox" value="整体" class="WT_sjlb_ch" name="WT_sjlb" />@Resource.String658
                                </td>
                                <td><span>*</span>@Resource.String659</td>
                                <td>
                                    <select id="WT_dj">
                                        <option value="null">----@Resource.String660----</option>
                                        <option value="A">A</option>
                                        <option value="B">B</option>
                                        <option value="C">C</option>
                                        <option value="D">D</option>
                                    </select>
                                </td>
                            </tr>
                            <tr style="display:none">
                                <td>
                                    <p></p>
                                </td>
                            </tr>
                            <tr>
                                <td rowspan="3"><span>*</span>@Resource.String661</td>
                                <td>@Resource.String662</td>
                                <td><input type="text" id="WT_cpzl" /></td>
                                <td></td>
                                <td>@Resource.String663</td>
                                <td><input type="text" id="WT_ddsm" /></td>
                            </tr>
                            <tr>
                                <td rowspan="2">设计要求</td>
                                <td rowspan="2" colspan="4"><textarea style="width: 100%; height: 100px;" id="WT_qtxx"></textarea></td>
                            </tr>
                            <tr style="display:none">
                            </tr>
                            <tr style="display:none">
                                <td>
                                    <p></p>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <p></p>
                                </td>
                            </tr>
                            <tr>
                                <td rowspan="9"><span>*</span>@Resource.String665</td>
                                <td>@Resource.String666</td>
                                <td colspan="4" id="WT_ysfs">
                                    <input type="checkbox" value="汽车运输" name="WT_ysfs" />@Resource.String667
                                    <input type="checkbox" value="铁路运输" name="WT_ysfs" />@Resource.String669
                                    <input type="checkbox" value="海轮运输" name="WT_ysfs" />@Resource.String671
                                    <input type="checkbox" value="航空运输" name="WT_ysfs" />@Resource.String673
                                    <input type="checkbox" value="其他" name="WT_ysfs" />@Resource.String675
                                </td>
                            </tr>
                            <tr>
                                <td>@Resource.String677</td>
                                <td colspan="4" id="WT_bzlx">
                                    <input type="checkbox" value="内包装" name="WT_bzlx" />@Resource.String678
                                    <input type="checkbox" value="外包装" name="WT_bzlx" />@Resource.String680
                                    <input type="checkbox" value="单独包装" name="WT_bzlx" />@Resource.String682
                                    <input type="checkbox" value="集合包装" name="WT_bzlx" />@Resource.String684
                                </td>
                            </tr>
                            <tr>
                                <td>@Resource.String686</td>
                                <td colspan="4" id="WT_fhyq">
                                    <input type="checkbox" value="防震处理" name="WT_fhyq" />@Resource.String687
                                    <input type="checkbox" value="防锈处理" name="WT_fhyq" />@Resource.String689
                                    <input type="checkbox" value="防霉处理" name="WT_fhyq" />@Resource.String691
                                    <input type="checkbox" value="防潮处理" name="WT_fhyq" />@Resource.String693
                                    <input type="checkbox" value="防静电处理" name="WT_fhyq" />@Resource.String695
                                    <input type="checkbox" value="屏蔽处理" name="WT_fhyq" />@Resource.String697
                                    <input type="checkbox" value="@Resource.String699" name="WT_fhyq" />@Resource.String699
                                </td>
                            </tr>
                            <tr>
                                <td rowspan="3">其他要求或信息</td>
                                <td rowspan="3" colspan="4"><textarea style="width: 100%; height: 100px;" id="WT_qtyq"></textarea></td>
                            </tr>
                            <tr></tr>
                            <tr></tr>
                            <tr>
                                <td rowspan="3">测试要求</td>
                                <td rowspan="3" colspan="4"><textarea style="width: 100%; height: 100px;" id="WT_csyq"></textarea></td>
                            </tr>
                            <tr></tr>
                            <tr></tr>
                            <tr>
                                <td>
                                    <p></p>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <span>*</span>@Resource.String718
                                </td>
                                <td colspan="5" id="WT_xmbzfjxx">
                                    <input type="checkbox" value="产品数据" name="WT_xmbzfjxx" />@Resource.String719
                                    <input type="checkbox" value="产品图纸" name="WT_xmbzfjxx" />@Resource.String721
                                    <input type="checkbox" value="包装图纸" name="WT_xmbzfjxx" />@Resource.String723
                                    <input type="checkbox" value="图片" name="WT_xmbzfjxx" />@Resource.String725
                                    <input type="checkbox" value="其他" name="WT_xmbzfjxx" />@Resource.String727
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4"></td>
                                <td>@Resource.String729</td>
                                <td><input type="text" id="WT_jdshy" class="Shu1" readonly /></td>
                            </tr>
                            <tr>
                                <td>@Resource.String730</td>
                                <td id="WT_wcrq" colspan="3"></td>
                                <td>@Resource.String731</td>
                                <td><input type="text" id="WT_wcshy" class="Shu1" readonly /></td>
                            </tr>
                        </tbody>
                    </table>
                </fieldset>
            </div>
        </div>
    </div>
    @*设计主管分配和审核设计图*@
    <div id="div5" style="display:none" class="col-sm-12">
        <div class="">
            <fieldset class="boun">
                <legend class="len">任务分配</legend>
                <table class="table">
                    <thead style="text-align:center;">
                    <thead>
                        <tr style="background-color:white;text-align:center">
                            <td>@Resource.String705</td>
                            <td>@Resource.String706</td>
                            <td>@Resource.String707</td>
                            <td>@Resource.String708</td>
                            <td>@Resource.String709</td>
                            <td></td>
                        </tr>
                    </thead>
                    <tbody id="WT_JDR_Tb">
                    </tbody>
                    <tfoot>
                        <tr>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td><a href="#" id="WT_JDR_TJ">@Resource.String710</a></td>
                        </tr>
                    </tfoot>
                </table>
                <div><button id="TJIAO_JDRF" style="margin-left:30px;">任务分配</button></div>
            </fieldset>
            <fieldset class="boun">
                <legend class="len">@Resource.String84</legend>
                <div class="div_A JNSSS">
                    <table class="table tab" style="width:160%;">
                        <thead style="text-align:center;">
                            <tr style="background-color: #6e95bc">
                                <td>序号</td>
                                <td>文件名</td>
                                <td>物料编码</td>
                                <td>上传时间</td>
                                <td>行业大类</td>
                                <td>行业小类</td>
                                <td>包装类别</td>
                                <td>图纸类别</td>
                                <td>版本</td>
                                <td>上传人</td>
                                <td>设计时长</td>
                                <td>状态</td>
                                <td>修改</td>
                                <td>操作</td>
                                <td>审核</td>
                            </tr>
                        </thead>
                        <tbody id="div5_tb">
                        </tbody>
                    </table>
                </div>
            </fieldset>
        </div>
    </div>
    @*设计委托注意事项*@
    <div id="APP_sjwt_bz" style="display:none">
        <div>
            * 带"*"由销售填写，其余由设计部门填写；任务单号由系统自动生成；
        </div>
        <div>
            * 接单审核人定义为设计部主管或其指定人员；申请审核人定义为客户经理；任务完成审核定义为设计部主管或其指定人员；
        </div>
        <div>
            * 设计类别中整体设计包含结构设计和平面设计；测试/标准要求没有要求的默认按照国标及兰多标准执行；
        </div>
        <div>
            * 等级分类说明：
        </div>
        <div>
            A级：一般设计类别为结构设计或平面设计；按照客户要求或者按照样品绘制简单结构图纸或者平面图纸（02/03/04系列箱型或则其他类型简单结构），或按照要求核算包装数据（材质，边压，耐破，抗压，重量等），或预计耗费20分钟以下的其他事物；
        </div>
        <div>
            B级：一般设计类别为结构设计或平面设计；按照客户要求或者样品绘制结构图纸+平面图纸或者复杂的结构图纸或则复杂的平面图纸，或按照要求绘制装柜图纸，或预计耗费20-60分钟的其他事物；
        </div>
        <div>
            C级：一般设计类别为整体设计；按照客户要求设计产品包括内衬/内箱/外箱等在内的成套包装设计（结构明细图纸，方案示意图，装柜示意图，平面图），或按照要求绘制装柜图纸，或耗费60-240分钟的其他事物；
        </div>
        <div>
            D级：一般设计类别为整体设计；按照客户要求设计产品复杂的成套包装方案包括内衬/内箱/外箱等在内的成套包装设计（结构明细图纸，方案示意图，装柜示意图，平面示意图），或多种材料综合运用的包装，或可循环类、料架类包装，或按照要求绘制装柜图纸，或耗费240分钟以上的其他事物。
        </div>
    </div>
    @*BOM模块*@
    <div class="col-12" data-spy="scroll" data-target="#navbar-example2" data-offset="0" id="APP_WLSQ">
        <fieldset class="boun">
            <legend class="len">@Resource.String90</legend>
            <div class="row Yinchande" id="shshj">
                @*<div class="col-2" id="xinzengWL">新增物料</div>*@
                <div class="col-2" id="addwl">@Resource.String91</div>
                <div class="col-2" id="Tiao">@Resource.String92</div>
                <div class="col-2" id="DELcheck">@Resource.String93</div>
                <div class="col-2" id="Copy">复制行</div>
            </div>
            <div>
                <div style="display:none" id="JINDN">
                    <lable id="XINzhengWL" style="color: blue; border-bottom: 1px solid blue; ">@Resource.String94</lable>
                    <lable style="color: blue; border-bottom: 1px solid blue;" id="xinzengWL">@Resource.String2001</lable>
                </div>
                <div id="Yin" style="display:none">
                    <a href="/Material/Ecssxsdd?shu=1" id="Xiaxz" style="color: blue; border-bottom: 1px solid blue; ">@Resource.String96</a>
                    <a style="color: blue; border-bottom: 1px solid blue;" id="ShangC">@Resource.String97</a>
                </div>
            </div>

            <div>
                <table class="table tab">
                    <thead style="text-align:center;">
                        <tr style="background-color: #6e95bc">
                            <th scope="col" style="width:20px;"><input type="checkbox" id="QXK" /></th>
                            <th scope="col">@Resource.String98</th>
                            <th scope="col">@Resource.String100</th>
                            <th scope="col">@Resource.String99</th> @*料号*@
                            <th scope="col">物料名</th> @*名字*@
                            <th scope="col">@Resource.String101</th>
                            <th scope="col">@Resource.String102</th>
                            <th scope="col">@Resource.String103</th>
                            <th scope="col">@Resource.String104</th>
                            <th scope="col">@Resource.String105</th>
                            <th scope="col">@Resource.String106</th>
                            <th scope="col">@Resource.String107</th>
                        </tr>
                    </thead>
                    @using (Html.BeginForm("AddAppli", "Application", FormMethod.Post))
                    {
                        <tbody data-spy="scroll" id="WLTable" style="background-color:#fff;height:300px">
                        </tbody>
                    }
                </table>
            </div>
        </fieldset>
    </div>
    @*BOM上传面板*@
    <div class="YCFile">
        <div class="YANds"><span>@Resource.String108</span><span><i class="bi bi-x-circle-fill" id="Quxiao"></i></span></div>
        <div class="SHnacs">
            <input type="file" value="" id="SHanngcF" accept="" />
            <input type="button" value="@Resource.String108" id="TIjaio" />
        </div>
    </div>
    <div id="TuzXZ" style="display: none; position: absolute; border: 1px black solid; left: 25%; top: 33%; background-color: white; background-color: #f1f1f1;height:200px;width:300px">
        <div style="text-align: right; background-color: #84acde;"><span class="WT_qxbh2" style=" margin: 20px;"><i class="bi bi-x-square"></i></span></div>
        <div style="margin: 20px 10px; padding: 10px; background-color: #fff;">
            <div id="WJ_XZLJ"></div>
        </div>
        <div style="text-align:center"><button class="WT_qxbh2">@Resource.String126</button></div>
    </div>
    @*新建物料和料号*@
    <div id="addwl_main" style="display: none; position: absolute; border: 1px black solid; left: 20%; top: 30%; background-color: white; background-color: #f1f1f1">
        <div style="text-align: right; background-color: #84acde;" class="Tuodong">点击这里拖动窗体<span class="quxiao" style=" margin: 20px;"><i class="bi bi-x-square"></i></span></div>
        <div style="margin: 20px 10px; padding: 10px; background-color: #fff;">
            <table id="addwl_main_tab">
                <tr><td style="color:red">@Resource.String1261</td></tr>
                <tr><td>层级</td><td><select id="LevenED"><option value="Leve0">Leve0</option><option value="leve1">leve1</option><option value="leve2">leve2</option></select></td></tr>
                <tr>
                    <td>@Resource.String512<span style="color:red">*</span></td>
                    <td><input type="text" id="amt_WLM" class="amt_v" /></td>
                    <td>@Resource.String111</td>
                    @*料号*@
                    <td><input type="text" id="amt_WLBM" class="" readonly /></td>
                </tr>
                <tr>
                    <td>@Resource.String112</td>
                    <td><input type="number" id="amt_NYL" class="amt_v" /></td>
                    <td>@Resource.String113</td>
                    <td>
                        <input type="text" name="Biaomian" value="" readonly />
                        <div style="display:none" id="Yinchangs" class="Dingdiv">
                            <div style="display: flex; justify-content: space-between;"><span id="TanT">添加</span> <span><i class="bi bi-x-circle-fill quxiaoshi"></i></span></div>
                            <ul style="height:100px;overflow-y:scroll" id="ULAP">
                                @foreach (var item in ViewBag.ZUI as List<jectsche>)
                                {
                                    <li><input type="checkbox" value="@item.Je_hanghao" class="Xuanz" />@item.Je_hanghao</li>
                                }
                            </ul>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>@Resource.String114</td>
                    <td><input type="text" id="amt_BMCL" class="amt_v" /></td>
                    <td>@Resource.String115</td>
                    <td><input type="text" id="amt_YCL" class="amt_v" /></td>
                </tr>
                <tr>
                    <td>@Resource.String116 <span style="color:red">*</span></td>
                    <td>
                        <select id="dl_wl" class="form-control">
                            <option value="0">请选择</option>
                            @foreach (var item in ViewBag.temp2 as List<buty3>)
                            {
                                <option value="@item.zl2_id">@item.zl2_name</option>
                            }
                        </select>
                    </td>
                    <td>@Resource.String120<span style="color:red">*</span></td>
                    <td>
                        <select class="form-control" id="leibei_x" placeholder="">
                            <option value="彩印纸箱">@Resource.String121</option>
                            <option value="水印拉链箱">@Resource.String1305</option>
                            <option value="水印瓦楞箱">@Resource.String1304</option>
                            <option value="瓦楞平板（规格≥500*250）">@Resource.String1306</option>
                            <option value="标签">@Resource.String1308</option>
                            <option value="说明书/卡片/折页">@Resource.String1309</option>
                            <option value="纸">@Resource.String1310</option>
                            <option value="纸护角">@Resource.String1311</option>
                            <option value="纸管">@Resource.String1312</option>
                            <option value="蜂窝制品">@Resource.String1313</option>
                            <option value="纸托盘">@Resource.String1314</option>
                            <option value="纸塑">@Resource.String1315</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>@Resource.String123 (mm)<span style="color:red">*</span></td>
                    <td><input type="number" class="amt_v guig" id="cahns" /></td>
                    <td>*<input type="number" class="amt_v guig" id="cahns1" /></td>
                    <td>*<input type="number" class="amt_v guig" id="cahns2" /></td>
                </tr>
                <tr>
                    <td>@Resource.String124</td>
                    <td><input type="text" id="amt_MS" class="amt_v" /></td>
                    <td>计量单位<span style="color:red">*</span></td>
                    <td>
                        <select id="amt_DW" style="width:100px;">
                            @foreach (var item in ViewBag.JIliang as List<Freht>)
                            {
                                <option value="@item.Fre_shijian">@item.Fre_beizhu</option>
                            }
                        </select>
                    </td>
                </tr>
                <tr><td>自制或外购</td><td><select id="shuxinss" style="width:100px;"><option value=""></option><option value="外购">外购</option><option value="自制">自制</option></select></td></tr>
            </table>
            @if (MyAuthentication.IsLogin())
            {
                if (MyAuthentication.GetUsers().DE_bumeng == 2)
                {
                    <table class="table">
                        <thead style="text-align:center;">
                            <tr style="background-color: #6e95bc">
                                <th>序号</th>
                                <th>文件名</th>
                                <th>料号</th>
                                <th>上传人</th>
                                <th>上传</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                        <tfoot>
                            <tr>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td><a id="show_shgcdiv">上传</a></td>
                            </tr>
                        </tfoot>
                    </table>
                }

            }

        </div>
        <div style=" display: flex; justify-content: center;"><button id="queding">@Resource.String125</button>&emsp;&emsp;<button class="quxiao">@Resource.String126</button></div>
    </div>

    @*添加起订量*@
    <div id="addwl_main" class="ZUIXIAO" style="display: none; position: absolute; border: 1px black solid; left: 32%; top: 43%; background-color: white; background-color: #f1f1f1">
        <div style="text-align: right; background-color: #84acde;">最小起订量添加<span class="shhhudb" style=" margin: 20px;"><i class="bi bi-x-square"></i></span></div>
        <div style="margin: 20px 10px; padding: 10px; background-color: #fff;">
            <input type="text" value="" class="HNFJI" />
        </div>
        <div style=" display: flex; justify-content: center;"><button id="JInRU">@Resource.String125</button>&emsp;&emsp;<button class="KOHUS">@Resource.String126</button></div>
    </div>
    @*设计图提交面板*@
    <div id="show_shangc" style="display: none; position: absolute; border: 1px black solid; left: 25%; top: 33%; background-color: white; background-color: #f1f1f1">
        <div style="text-align: right; background-color: #84acde;" class="Tuodong"><span class="QUED_quxiao" style=" margin: 20px;"><i class="bi bi-x-square"></i></span></div>
        <div style="margin: 20px 10px; padding: 10px; background-color: #fff;">
            <div><span>请输入设计用时</span><input type="number" id="SLong" /></div>
            <p></p>
            <div><input type="file" id="SCWJ_SJ" multiple /></div>
            <table>
                <tr>
                    <td class="form-group">
                        <label for="CL_email" class=" control-label">@Resource.String80</label>
                    </td>
                    <td class="">
                        <select class="form-control" id="SJ_HANG1" placeholder="行业大类" name="hangye1">
                            <option value="">--@Resource.String48--</option>
                            @foreach (var item in ViewBag.ic as List<IndustryCategory>)
                            {
                                <option value="@item.ic_id" id="CL_ID">@item.ic_name</option>
                            }
                        </select>
                    </td>
                    <td class="form-group">
                        <label for="CL_email" class=" control-label">@Resource.String81</label>
                    </td>
                    <td class="">
                        <select class="form-control" id="SJ_HANG2" placeholder="行业小类" name="hangye2">
                            <option value="">--@Resource.String63--</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="form-group">
                        <label for="CL_email" class=" control-label">包装品类</label>
                    </td>
                    <td class="">
                        <select class="form-control" id="TZ_BZPL" placeholder="包装品类" name="hangye1">
                            <option value="0">--@Resource.String48--</option>
                            <option value="纸质产品">纸质产品</option>
                            <option value="木制品">木制品</option>
                            <option value="塑料制品">塑料制品</option>
                            <option value="泡沫防护产品">泡沫防护产品</option>
                            <option value="可回收的">可回收的</option>
                            <option value="包装配件">包装配件</option>
                            <option value="多种材质">多种材质</option>
                            <option value="其他">其他</option>
                        </select>
                    </td>
                    <td class="form-group">
                        <label for="CL_email" class=" control-label">图纸类别</label>
                    </td>
                    <td class="">
                        <select class="form-control" id="TZ_TZLB" placeholder="图纸类别" name="hangye2">
                            <option value="0">--@Resource.String48--</option>
                            <option value="结构图">结构图</option>
                            <option value="印刷图">印刷图</option>
                            <option value="套件">套件</option>
                            <option value="SOP(操作指导）">SOP(操作指导）</option>
                            <option value="测试报告">测试报告</option>
                            <option value="其他">其他</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="form-group">
                        <label for="CL_email" class=" control-label">@Resource.String82</label>
                    </td>
                    <td class="">
                        <input type="text" class="form-control" id="SJ_bzwmc" placeholder="包装物名称" name="zhongduan">
                    </td>
                    <td class="form-group">
                        <label for="CL_email" class=" control-label">@Resource.String806</label>@*图纸版本*@
                    </td>
                    <td class="">
                        <select type="text" class="form-control" id="TZ_BB" placeholder="@Resource.String806" name="zhongduan"  list="BB_S"></select>
                        
                    </td>
                </tr>
            </table>
        </div>
        <div style="display: flex; justify-content: center"><button id="QUEding_SCOP">@Resource.String125</button><button id="QUEding_SC">@Resource.String125</button>&emsp;&emsp;<button class="QUED_quxiao">@Resource.String126</button></div>
    </div>

    @*设计图驳回面板*@
    <div id="WT_dh_mb" style="display:none;position:fixed;background-color:white;top:200px;width:660px;left:300px;z-index:1000;border:1px black solid;">
        <div id="WJ_ID" style="display:none"></div>
        <div id="WJ_tjr" style="display:none"></div>
        <table>
            <tr>
                <td>@Resource.String548：</td>
                <td id="WT_dhr"></td>
            </tr>
            <tr>
                <td>@Resource.String549</td>
                <td><textarea id="WT_dhly"></textarea></td>
            </tr>
            <tr>
                <td id="WT_qdbh">@Resource.String550</td>
                <td id="WT_qxbh">@Resource.String551</td>
            </tr>
        </table>
    </div>

    <div id="WT_dh_mb2" style="display:none;position:fixed;background-color:white;top:200px;width:660px;left:300px;z-index:1000;border:1px black solid;">
        <table>
            <tr>
                <td>@Resource.String632：</td>
                <td id="WT_dhr2"></td>
            </tr>
            <tr>
                <td>请选择设计委托驳回到的节点</td>
                <td style="display:block" id="xianlw">
                    <select id="WT_SJWt">
                        <option value="1">销售信息填写</option>
                        <option value="2">设计主管分配</option>
                        <option value="3">设计人员上传</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>@Resource.String633</td>
                <td><textarea id="WT_dhly2"></textarea></td>
            </tr>
            <tr>
                <td id="WT_qdbh2">@Resource.String634</td>
                <td id="WT_qxbh2">@Resource.String635</td>
            </tr>
        </table>
    </div>

    <div id="WT_dh_mb3" style="display:none;position:fixed;background-color:white;top:200px;width:660px;left:300px;z-index:1000;border:1px black solid;">
        <table>
            <tr>
                <td>@Resource.String548：</td>
                <td id="WT_dhr3"></td>
            </tr>
            <tr>
                <td>@Resource.String549</td>
                <td><textarea id="WT_dhly3"></textarea></td>
            </tr>
            <tr>
                <td id="WT_qxbh3">@Resource.String551</td>
            </tr>
        </table>
    </div>
    @*图纸审批界面*@
    <div id="TZsj" style="display: none; position: absolute; border: 1px black solid; left: 25%; top: 33%; background-color: white; background-color: #f1f1f1">
        <div style="text-align: right; background-color: #84acde;" class="Tuodong"><span class="NOKM" style=" margin: 20px;"><i class="bi bi-x-square"></i></span></div>
        <div style="margin: 20px 10px; padding: 10px; background-color: #fff;">
            <p id="JINFHH" style="display:none"></p>
            <div><span>请输入审核用时：</span><input type="number" id="SHtime" /></div><br />
            <div><span>请输入审核说明：</span><textarea id="SHmiao"></textarea></div>
        </div>
        <div style="text-align:center"><button id="WT_pass">@Resource.String125</button>&emsp;&emsp;<button class="NOKM">@Resource.String126</button></div>
    </div>
</div>


<div style="display:none" id="DE_ID_1">0</div>


@section scripts
{
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script>
        $(function () {
            var namd = $("#appp_Sjzt").text()
            if (namd == "设计委托") {
                $("#li2").css({ "color": "black", "background-color": "white" })
            }
            else {
                $("#li1").css({ "color": "black", "background-color": "white" })
            }

            $("input,select").attr({ "autocomplete": "off"})
            var amsndol = $("#Login_N").text()
            $("#WT_sqr").val(amsndol)
            Liaohao()//料号编号
            SKFS()
            
            $(".shhhudb,.KOHUS").click(function () {
                $(".ZUIXIAO").hide()
            })
            $(document).on("click", "#Selse", function (e) {
                var index = $(e.target).val()
                if (index == "Y" || index == "S") {
                    $("#divweituo").css({ "display": "block" })
                }
                else {
                    $("#divweituo").css({ "display": "none" })
                }
            })
            $("#QXK").click(function () {
                if ($("#QXK").prop("checked") == true) {
                    console.log(1)
                    $(".XANZK").prop("checked", true)
                }
                else {
                    $(".XANZK").prop("checked", false)
                }
            })
            $("#TanT").click(function () {
                $(".ZUIXIAO").show()
            })
            //点击打开上传文件
            $(document).on("click", "#show_shgcdiv", function (e) {
                const WL = $("#amt_WLBM").val()//物料编码
                const BM = $("#txtdan").val()//物料编码
                const name = $("#Login_name").text()//物料编码
                $("#TZ_BB option").remove()
                $.ajax({
                    url: '/Application/FileVerison1',
                    type: 'POST',
                    data: { "BM": BM, "name": name },
                    success: function (zc) {
                        const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                        const HN = (zc * 1) >= 2 ? zc * 1 - 2 : 0;
                        for (var i = HN; i < zc*1+1; i++) {
                            $op = $("#TZ_BB").append("<option value='" + alphabet[i] + "'>" + alphabet[i] + "</option>")
                        }
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
                $("#SJ_HANG1").val($("#hangye1").val())
                $("#SJ_HANG1").trigger("change")
                $("#QUEding_SCOP").css({ "display": "none" })
                $("#QUEding_SC").css({ "display": "block" })
                $("#show_shangc").css({ "display": "block" })
                $("#DE_ID_1").text(0)
                $("#SJ_bzwmc").val($("#txtbaozuang").val())
            })
            //点击图纸重新上传
            $(document).on("click", "#log_SXSC", function (e) {
                var id = $(e.target).parent().parent().children().eq(0).text()
                var temp = $(e.target).parent().parent().children().eq(10).text()
                if ($("#Login_sf").text() == "设计主管" || $("#Login_sf").text() == "设计经理") {
                    $("#show_shangc").css({ "display": "block" })
                    $("#QUEding_SC").css({ "display": "none" })
                    $("#DE_ID_1").text(id)
                }
                else if (temp == $("#Login_N").text()) {
                    $.ajax({
                        url: '/Contracts/Inspect_Contracts',
                        type: 'GET',
                        data: { "state": 3, "D_ID": $("#Login_name").text(), "D_Ton": $("#txtdan").val() },
                        success: function (zc) {
                            $.each(zc, function (i, obj) {
                                if (obj.SJ_ZT == "完成") {
                                    alert("已递交，无法删除")
                                }
                                else {
                                    $("#show_shangc").css({ "display": "block" })
                                    $("#DE_ID_1").text(id)
                                    $("#QUEding_SCOP").css({ "display": "block" })
                                    $("#QUEding_SC").css({ "display": "none" })
                                }
                            })
                        },
                        error: function () {
                            alert('Request Error');
                        }
                    })
                }
                else {
                    alert("只有上传人和设计主管可以重新上传")
                }
            })
            function SKFS() {
                $.ajax({
                    url: '/Application/Application',
                    type: 'POST',
                    data: { "state": 36},
                    success: function (path) {
                        $("#Loishud_sj option").remove()
                        $.each(path, function (i, item) {
                            var HUJNN = item[2] == "1" ? "应收单业务日期" : item[2] == "2" ? "订单日期" : item[2] == "3" ? "出库日期" : "";
                            var $op = (`<option value="${item[0]}">${HUJNN}</option>`)
                            $("#Loishud_sj").append($op)
                        })
                    },
                    error: function () {
                        alert("系统错误!");
                    }
                })
            }
            $("#JInRU").click(function () {
                var shund = $(".HNFJI").val()
                $.ajax({
                    url: '/Application/Application',
                    type: 'POST',
                    data: { "state": 20, "husJI": shund },
                    success: function (path) {
                        alert(path)
                        if (path == "添加成功") {
                            var $LI = $(`<li><input type="checkbox" value="${shund}" class="Xuanz" />${shund}</li>`)
                            $("#ULAP").append($LI)
                        }
                        $(".ZUIXIAO").hide()
                    },
                    error: function () {
                        alert("系统错误!");
                    }
                })
            })
            //点击图纸删除
            $(document).on("click", "#log_SC", function (e) {

                var id = $(e.target).parent().parent().children().eq(0).text()
                var temp = $(e.target).parent().parent().children().eq(10).text()

                console.log(id)
                if ($("#Login_sf").text() == "设计主管" || $("#Login_sf").text() == "设计经理") {
                    $.ajax({
                        url: '/Application/Application',
                        type: 'POST',
                        data: { "state": 13, "id": id },
                        success: function (path) {
                            alert(path)
                            Load_design_table()
                        },
                        error: function () {
                            alert("系统错误!");
                        }
                    })
                }
                else if (temp == $("#Login_N").text()) {
                    $.ajax({
                        url: '/Contracts/Inspect_Contracts',
                        type: 'GET',
                        data: { "state": 3, "D_ID": $("#Login_name").text(), "D_Ton": $("#txtdan").val() },
                        success: function (zc) {
                            $.each(zc, function (i, obj) {
                                if (obj.SJ_ZT == "完成") {
                                    alert("已递交，无法删除")
                                }
                                else {
                                    $.ajax({
                                        url: '/Application/Application',
                                        type: 'POST',
                                        data: { "state": 13, "id": id },
                                        success: function (path) {
                                            alert(path)
                                            Load_design_table()
                                        },
                                        error: function () {
                                            alert("系统错误!");
                                        }
                                    })
                                }
                            })
                        },
                        error: function () {
                            alert('Request Error');
                        }
                    })
                }
                else {
                    alert("只有上传人和设计主管可以删除")
                }

            })
            //关闭文件上传
            $(document).on("click", "#QUED_quxiao", function (e) {
                $("#show_shangc").css({ "display": "block" })
                $("#SCWJ_SJ").val("")
                $("#SLong").val("")
            })
            //点击上传文件
            $(document).on("click", "#QUEding_SC", function () {
                //获取文件名
                var fileUpload = $('#SCWJ_SJ').get(0).files;
                var fileName = fileUpload[0].name;
                var name = $("#Login_N").text();
                var shen = $("#txtdan").val();
                const DE_BB = $("#TZ_BB").val()
                $.ajax({
                    url: "/Application/FileVerison",
                    type: 'POST',
                    data: { "fileName": fileName, "name": name, "shen": shen, "BB": DE_BB },
                    success: function (text) {
                        if (text) {
                            Upload_attachment()
                        }
                    },
                    error: function (text) {
                        alert("系统错误");
                    }
                })
            })
            $(document).on("click", ".xiaosd", function () {
                var CG_XX=[]
                CG_XX.push({
                    AP_bian: $("#txtdan").val()
                })
                var userInput = prompt("请输入文件名：", "");
                if (userInput != null) {
                    $.ajax({
                        url: "/Application/TuZPLExcel",
                        type: 'POST',
                        data: { "application": CG_XX, "ades": userInput },
                        success: function (text) {
                            $("#TuzXZ").css({ "display": "block" })
                            $("#WJ_XZLJ").append($(`<a href="/Contracts/Download_file?path=${text}" id="log_SZ" class="WT_qxbh2">下载</a>`))
                        },
                        error: function (text) {
                            alert("系统错误");
                        }
                    })
                }
            })
            //关闭文件上传
            $(document).on("click", ".QUED_quxiao", function () {
                $("#show_shangc").css({"display":"none"})
            })
            $(document).on("click", ".WT_qxbh2", function () {
                $("#TuzXZ").css({ "display": "none" })
                $("#WJ_XZLJ a").remove()
            })
            //上传项目附件
            $(document).on("click", "#log_SCFJ", function () {
                Upload_attachmentfujian()
            })
            //上传备注的方法
            $(document).on("click", "#RZ_tjrz", function () {
                var now = new Date($.now());
                var year = (now.getFullYear()).toString();
                var month = (now.getMonth() + 1).toString();
                var date = (now.getDate()).toString();
                var hours = (now.getHours()).toString()
                var minutes = (now.getMinutes()).toString()
                var name = $("#Login_N").text()
                //组合当前日期
                var sqrq = year + "-" + month + "-" + date + " " + hours + ":" + minutes
                var rzxx = {
                    B_Bian: $("#txtdan").val(),
                    B_BR: name,
                    B_Date: sqrq,
                    B_bei: $('#RZ_xznr').val(),
                };
                console.log(rzxx)
                $.ajax({
                    url: "/Contracts/AddLogs",
                    type: "POST",
                    data: rzxx,
                    success: function (data) {
                        gettbz()
                        $('#RZ_xznr').val("")
                    },
                    error: function (data) {
                        alert("erroer");
                    },
                })
            })
            function formatDateTime(date = new Date()) {
                const year = date.getFullYear();
                const month = String(date.getMonth() + 1).padStart(2, '0');
                const day = String(date.getDate()).padStart(2, '0');
                const hours = String(date.getHours()).padStart(2, '0');
                const minutes = String(date.getMinutes()).padStart(2, '0');
                return `${year}-${month}-${day} ${hours}:${minutes}`;
            }
            //上传附件
            async function Upload_attachmentfujian() {
                var fileUpload = $('#SC_FJ_Wj').get(0).files;
                if (!fileUpload || fileUpload.length === 0) {
                    alert('请选择要上传的文件！');
                    return;
                }
                var name = $("#Login_N").text();
                var shen = $("#txtdan").val();

                try {
                    for (const file of fileUpload) {
                        const filename = file.name;
                        const sqrq = formatDateTime();
                        const fileData = new FormData();
                        fileData.append('file', file);

                        // 1. 上传文件
                        const response = await $.ajax({
                            url: "/Contracts/AddNdardo",
                            type: "POST",
                            contentType: false,
                            processData: false,
                            data: fileData
                        });

                        // 2. 保存文件信息
                        const BZJG = [{
                            DE_dizhi: response,
                            DE_shijian: sqrq,
                            DE_shen: shen,
                            De_ren: name,
                            DE_lei: "附件",
                            DE_TZname: filename
                        }];

                        await $.ajax({
                            url: '/Contracts/adddes',
                            type: 'POST',
                            contentType: "application/json;charset=utf-8",
                            dataType: "json",
                            data: JSON.stringify(BZJG)
                        });
                    }
                    Load_design_table();
                    $("#show_shangc").hide();
                    alert("上传成功！");
                } catch (error) {
                    console.error('上传失败：', error);
                    alert('上传失败，请重试！');
                }
            }
            //上传设计图纸
            async function Upload_attachment() {
                var id = $("#DE_ID_1").text();
                var lei2 = $("#SJ_HANG1").val() || null;
                var fileUpload = $('#SCWJ_SJ').get(0).files;
                var shji = $("#SLong").val();
                var name = $("#Login_N").text();
                // 校验必填项
                if (!fileUpload || fileUpload.length === 0) {
                    alert('请选择要上传的文件！');
                    return;
                }
                if (!shji) {
                    alert("请输入设计用时");
                    return;
                }
                if (!$("#SJ_HANG1").val() || !$("#SJ_HANG2").val() || !$("#TZ_BZPL").val() ||
                    !$("#TZ_TZLB").val() || !$("#SJ_bzwmc").val() || !$("#TZ_BB").val()) {
                    alert("必填项不能为空！");
                    return;
                }

                try {
                    for (const file of fileUpload) {
                        const filename = file.name;
                        const sqrq = formatDateTime();
                        const fileData = new FormData();
                        fileData.append('file', file);

                        // 1. 上传文件
                        const response = await $.ajax({
                            url: "/Contracts/AddNdardo",
                            type: "POST",
                            contentType: false,
                            processData: false,
                            data: fileData
                        });
                        console.log(response)
                        // 2. 保存文件信息
                        const BZJG = [{
                            DE_id: id,
                            DE_dizhi: response, // 假设返回的是数组
                            DE_shijian: sqrq,
                            DE_shen: $("#txtdan").val(),
                            De_ren: name, // 确保 `name` 已定义
                            DE_Slong: shji, // 修复：使用 `shji` 而不是未定义的 `SLong`
                            DE_tuiLei: "待审核",
                            bom_id: $("#amt_WLBM").val(),
                            DE_lei: "图纸",
                            DE_h1_id: $("#SJ_HANG1").val(),
                            DE_h2_id: lei2,
                            DE_bzpl: $("#TZ_BZPL").val(),
                            DE_tzlb: $("#TZ_TZLB").val(),
                            DE_bzw: $("#SJ_bzwmc").val(),
                            DE_BB: $("#TZ_BB").val(),
                            DE_TZname: filename
                        }];
                        console.log(BZJG)
                        await $.ajax({
                            url: '/Contracts/adddes',
                            type: 'POST',
                            contentType: "application/json;charset=utf-8",
                            dataType: "json",
                            data: JSON.stringify(BZJG)
                        });
                    }

                    Load_design_table();
                    $("#show_shangc").hide();
                    alert("上传成功！");
                } catch (error) {
                    console.error('上传失败：', error);
                    alert('上传失败，请重试！');
                }

            }
            //点击打开新增供应商
            $(document).on("click", "#XINzhengWL", function () {
                Liaohao()
                $("#amt_DW").val("Pcs")
                $("#amt_WLM").removeAttr("readonly")
                $("#addwl_main").css({ "display": "block" })
            })
            $(document).on("click", "#QUEding_SCOP", function () {
                var BZJG = [];
                BZJG.push({
                    DE_id: $("#DE_ID_1").text(),
                    DE_h1_id: $("#SJ_HANG1").val(),
                    DE_h2_id: $("#SJ_HANG2").val(),
                    DE_bzpl: $("#TZ_BZPL").val(),
                    DE_tzlb: $("#TZ_TZLB").val(),
                    DE_bzw: $("#SJ_bzwmc").val(),
                })
                console.log(BZJG)
                if ($("#SJ_HANG1").val() == "") {
                    alert("必填项不能为空！")
                } else if ($("#SJ_HANG2").val() == null && $("#SJ_HANG2").val() == "") {
                    alert("必填项不能为空！")
                } else if ($("#TZ_BZPL").val() == "") {
                    alert("必填项不能为空！")
                } else if ($("#TZ_TZLB").val() == "") {
                    alert("必填项不能为空！")
                } else if ($("#SJ_bzwmc").val() == "") {
                    alert("必填项不能为空！")
                } else if ($("#TZ_BB").val() == "") {
                    alert("图纸版本不能为空！")
                } else {
                    //获取文件名
                    var fileUpload = $('#SCWJ_SJ').get(0).files;
                    var fileName = fileUpload[0].name;
                    var name = $("#Login_N").text();
                    var shen = $("#txtdan").val();
                    const DE_BB = $("#TZ_BB").val()
                    $.ajax({
                        url: "/Application/FileVerison",
                        type: 'POST',
                        data: { "fileName": fileName, "name": name, "shen": shen, "BB": DE_BB },
                        success: function (text) {
                            if (text) {
                                $.ajax({
                                    url: '/Contracts/UpdateDes',
                                    type: 'POST',
                                    contentType: "application/json;charset=utf-8", // 不设置内容类型
                                    dataType: "json",
                                    processData: false, // 不处理数据
                                    data: JSON.stringify(BZJG),
                                    success: function (response) {
                                        if (response == "") {
                                            alert("修改失败！")
                                        } else {
                                            Load_design_table()
                                            alert("修改成功！")
                                            $('#SCWJ_SJ').val("")
                                            $("#show_shangc").css({ "display": "none" })
                                        }
                                    },
                                    error: function (jqXHR, textStatus, errorMessage) {
                                        alert('AJAX请求失败：' + errorMessage);
                                    }
                                });
                            }
                        },
                        error: function (text) {
                            alert("系统错误");
                        }
                    })
                }
            })
            $("#addwl").click(function () {
                $("#JINDN").toggle()
                $("#Yin").hide()
            })
            //新增和删除物料行
            $(function () {
                $("#xinzengWL").click(function () {
                    var $tr = $(`
                                    <tr id="WLtr">
                                        <td style="width:20px;"><input type="checkbox"class="XANZK"/></td>
                                        <td><lable id="labes">Leve0</lable></td>
                                        <td><a id="app_CkWl" href="#">物料信息</a></td>
                                        <td><input type="text"class="inwei"name="empLiao" id="empLiao" list="seleect_codes"/>
                                            <datalist id="seleect_codes" class="form-control" style="display:none"></datalist></td>
                                        <td>
                                            <input type="text" id="empName" class="inwei" name="empName"  />
                                        </td>
                                        <td><input type="text"class="inwei" name="empMiao" id="empMiao" /></td>
                                        <td><input type="number"class="inwei" name="empNian" min="0" max="1000000"/></td>
                                        <td>
                                        <input type="text" id="txtxun" class="inwei" name="CL_name" list="select_codes" />
                                            <datalist id="select_codes" class="form-control" style="display:none">
                                            @foreach (var item in ViewBag.JIliang as List<Freht>)
                                            {
                                                <option value="@item.Fre_shijian">@item.Fre_beizhu</option>
                                            }
                                            </datalist>
                                        </td>
                                        <td >
                                        <input type="text" id="leibie" class="inwei" />
                                        </td>
                                        <td id="jisndd">
                                         <input type="text" id="leib_ji" class="inwei" />
                                        </td>
                                        <td><input type="number" class="inwei" name="empYong" value="1"/></td>
                                        <td>
                                        <input type="text" id="txtxuns" class="inwei" name="CL_Gong" list="select_Lei" />
                                            <datalist id="select_Lei" class="form-control" style="display:none">
                                            <option>--@Resource.String63--</option>
                                            <option value="外购">@Resource.String130</option>
                                            <option value="自制">@Resource.String131</option>
                                            </datalist>
                                        </td>
                                        <td style="display:none">1</td>
                                        <td style="display:none"></td>
                                    </tr>
                                    `);
                    $('#WLTable').append($tr);
                    $("input,select").attr({ "autocomplete": "off" })
                })
            })
            $(document).on("click", ".quxiao", function () {
                $("#addwl_main").css({ "display": "none" })
                $("#queding").css({ "display": "block" })
                $(".amt_v").val("")
            })
            //点击切换物料一级和二级类别

            //显示ERP组织
            Zuzhi()
            function Zuzhi() {
                $.ajax({
                    url: '/Application/Application',
                    type: 'POST',
                    data: { "state": 7 },
                    success: function (path) {
                        if (path == "获取错误") {
                            alert(path)
                        } else {
                            carOPt(path)
                        }
                    },
                    error: function () {
                        alert("系统错误!");
                    }
                })
            }
            function carOPt(DL) {
                $("#SelZZ option").remove()
                $.each(DL, function (i, item) {
                    var $op = $(`<option value="${item[0]}">${item[1]}</optino>`)
                    $("#SelZZ").append($op)
                })
                $("#SelZZ").val("10.01")
            }
            //表面
            $('input[name="Biaomian"]').click(function () {
                $("#Yinchangs").toggle();
            })
            $('.quxiaoshi').click(function () {
                $("#Yinchangs").toggle();
            })

            //点击确定按钮//表面
            $(document).on("change", ".Xuanz", function () {
                $('input[name="Biaomian"]').val("")
                $("#Yinchangs").find("input[type='checkbox']").each(function () {
                    if ($(this).prop("checked")) {
                        $('input[name="Biaomian"]').val($('input[name="Biaomian"]').val() + ($('input[name="Biaomian"]').val() == "" ? "" : ",") + $(this).val())
                        $(this).prop('checked', true)
                        $(this).prop('disabled', false)
                    }
                });
            })
            //新增物料
            $(document).on("click", "#queding", function () {
                addwuliao()
            })

            //查看物料信息
            $(document).on("click", "#app_CkWl", function (e) {
                getMaterialInformation($(e.target))
            })

            //修改产品二级类别
            $(document).on("change", "#dl_wl", function (e) {
                var id = $(e.target).val()
                $.ajax({
                    url: '/Admin/Purchasing_Authority',
                    type: 'GET',
                    data: { "id": id, "state": 4 },
                    success: function (data) {
                        $("#leibei_x option").remove()
                        $.each(data, function (i, item) {
                            $("#leibei_x").append($(`<option value="${item.zl_name}">${item.zl_name}</option>`))
                        })
                    },
                    error: function () {
                        alert('Request Error');
                        Getquanx()
                    }
                })
            })
            $(document).on("change", "#leibie", function (e) {
                var id = $(e.target).val()
                $.ajax({
                    url: '/Admin/Purchasing_Authority',
                    type: 'GET',
                    data: { "id": id, "state": 4 },
                    success: function (data) {
                        $(e.target).parent().next().children().children().remove()
                        $.each(data, function (i, item) {
                            $(e.target).parent().next().children().append($(`<option value="${item.zl_name}">${item.zl_name}</option>`))
                        })
                    },
                    error: function () {
                        alert('Request Error');
                        Getquanx()
                    }
                })
            })
            //提交物料的方法
            function addwuliao() {
                var temp7 = $("#dl_wl").val()
                temp7 = temp7 == "1" ? "纸质" : temp7 == "2" ? "木质" : temp7 == "3" ? "塑料" : temp7 == "4" ? "金属制品" : temp7 == "5" ? "布" : temp7 == "6" ? "胶粘制品" : temp7 == "7" ? "其他" : temp7 == "8" ? "套件" : temp7;
                var GUIGE = "";
                var intkom = $(".guig").length;
                var int = 1;
                $(".guig").each(function (i, gg) {
                    if (intkom > int) {
                        GUIGE += $(gg).val() + "*"
                    } else {
                        GUIGE += $(gg).val()
                    }
                    int++;
                })
                var bm = $("#Login_bm").text()
                var d = 0;
                if (bm == "设计") {
                    d=1
                }
                else {
                    d=2
                }
                var JNFM = $("#LevenED").val()
                console.log(JNFM)
                var application = {
                    FM_bai: $("#amt_WLBM").val(),
                    FM_name: $("#amt_WLM").val(),
                    FM_nyl: $('#amt_NYL').val(),
                    FM_zx: $('#txtqishi').val(),
                    FM_yj: temp7,
                    FM_ej: $('#leibei_x').val(),
                    FM_bmcl: $('#amt_BMCL').val(),
                    FM_ycl: $('#amt_YCL').val(),
                    FM_ms: $('#amt_MS').val(),
                    FM_gg: GUIGE,
                    FM_ji: $("#amt_DW").val(),
                    FM_long: $("#cahns").val(),
                    FM_kuan: $("#cahns1").val(),
                    FM_gao: $("#cahns2").val(),
                    FM_Jieti: $("input[name='Biaomian']").val(),
                    FM_Zhuang: $("#shuxinss").val(),
                    FM_price: d
                };
                console.log(application)

                //bom heding
                if (application.FM_name != "" && application.FM_ej != "" && application.FM_ej != "" && application.FM_gg != "") {
                    if (application.FM_long == "" && application.FM_kuan == "" && application.FM_gao == "") {
                        alert("规格数据不符合要求")
                        return
                    }
                    if (application.FM_Jieti=="") {
                        alert("最小起订量需要选择")
                        return
                    }
                    if (application.FM_Zhuang == "") {
                        alert("物料需要选择自制或外购")
                        return
                    }
                    if (JNFM == "") {
                        alert("请选择物层级！")
                        return
                    }
                    if (temp7 == "0") {
                        alert("请选择物料一级分类！")
                        return
                    }
                    $.ajax({
                        url: "/Application/Addfor",
                        type: "POST",
                        data: { "applications": application, "names": $("#txtdan").val()} ,
                        success: function (data) {
                            if (data == "修改成功") {
                                get_BOM_H()
                            } else if (data == "修改失败") {
                                alert(data)
                            } else {
                                AppendBOMLine()
                            }
                            $("#addwl_main").css({ "display": "none" })
                            $(".amt_v").val("")
                        },
                        error: function () {
                            alert("erroer");
                        },
                    })
                } else {
                    alert("请输入必须字段")
                }
            }
            //增加BOM行
            function AppendBOMLine() {
                var GUIGE = "";
                var intkom = $(".guig").length;
                var int = 1;
                $(".guig").each(function (i, gg) {
                    if (intkom > int) {
                        GUIGE += $(gg).val() + "*"
                    } else {
                        GUIGE += $(gg).val()
                    }
                    int++;
                })
                var temp = $("#amt_WLBM").val()
                var temp1 = $("#amt_WLM").val()
                var temp2 = $("#amt_NYL").val()
                var temp3 = $("#amt_BMCL").val()
                var temp4 = $("#amt_YCL").val()
                var temp5 = $("#amt_GG").val()
                var temp6 = $("#amt_MS").val()
                var temp7 = $("#dl_wl").val()
                var temp8 = $("#leibei_x").val()
                var temp9 = $("#amt_DW").val()
                var temp10 = $("#shuxinss").val()
                var temp11 = $("#LevenED").val()
                temp7 = temp7 == "1" ? "纸质" : temp7 == "2" ? "木质" : temp7 == "3" ? "塑料" : temp7 == "4" ? "金属制品" : temp7 == "5" ? "布" : temp7 == "6" ? "胶粘制品" : temp7 == "7" ? "其他" : temp7 == "8" ? "套件" : temp7;
                var $tr = $(` <tr id="WLtr">
                                <td style="width:20px;"><input type="checkbox" class="XANZK"/></td>
                                <td><lable id="labes">${temp11}</lable></td>
                                <td><a id="app_CkWl" href="#">物料信息</a></td>
                                <td ><input type="text" class="inwei" name="empLiao" id="empLiao" value="${temp}" /></td>
                                <td ><input type="text" class="inwei" name="empName" id="empName" value="${temp1}" /></td>
                                <td ><input type="text" class="inwei" name="empMiao" id="empMiao" value="${GUIGE}" /></td>
                                <td ><input type="number" class="inwei" name="empNian" min="0" max="1000000" value="${temp2}" /></td>
                                <td>
                                    <input type="text" id="txtxun" class="inwei" name="CL_name" list="select_codes" value="${temp9}"/>
                                    <datalist id="select_codes" class="form-control" style="display:none">
                                        @foreach (var item in ViewBag.JIliang as List<Freht>)
                                            {
  <option>@item.Fre_beizhu</option>
                                            }
                                    </datalist>
                                </td>
                                <td id="B_BMCL"><input type="text" class="inwei" id="leibie" value="${temp7}" /></td>
                                <td id="B_YCL"><input type="text" class="inwei" id="leib_ji" value="${temp8}" /></td>
                                <td id="B_MS"><input type="number" class="inwei" name="empYong" value="1" /></td>
                                <td>
                                    <input type="text" id="txtxuns" class="inwei" name="CL_Gong" list="select_Lei" value="${temp10}"/>
                                    <datalist id="select_Lei" class="form-control" style="display:none">
                                        <option>--@Resource.String63--</option>
                                        <option value="外购">@Resource.String130</option>
                                        <option value="自制">@Resource.String131</option>
                                    </datalist>
                                </td>
                                <td style="display:none">1</td>
                                <td style="display:none"></td>
                            </tr>`);
                $('#WLTable').append($tr);
            }

            //复制物料行
            $(document).on("click", "#Copy", function (e) {
                //获取选中行
                var formation = [];
                var Cheng = "";
                $("input[class='XANZK']:checked").each(function (index, obj) {
                    var shunnn = $(obj).parent().parent().children().eq(3).children().val()
                    Cheng = $(obj).parent().parent().children().eq(1).text()
                    if (shunnn != "") {
                        formation.push({
                            FM_bai: shunnn,
                            FM_name: $("#txtdan").val(),
                        })
                    }
                })
                console.log("共" + formation.length + "数据");
                console.log(formation);
                if (formation.length > 0) {
                    //通过选中的行进行复制
                    $.ajax({
                        url: '/Application/BOMCopyH',
                        type: 'POST',
                        data: JSON.stringify(formation),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (path) {
                            var jm = path.length-1
                            console.log(jm)
                            $.each(path, function (i, item) {
                                var $tr = $(` <tr id="WLtr">
                                <td style="width:20px;"><input type="checkbox" class="XANZK"/></td>
                                <td><lable id="labes">${Cheng}</lable></td>
                                <td><a id="app_CkWl" href="#">物料信息</a></td>
                                <td ><input type="text" class="inwei" name="empLiao" id="empLiao" value="${item.FM_bai}" /></td>
                                <td ><input type="text" class="inwei" name="empName" id="empName" value="${item.FM_name}" /></td>
                                <td ><input type="text" class="inwei" name="empMiao" id="empMiao" value="${item.FM_gg}" /></td>
                                <td ><input type="number" class="inwei" name="empNian" min="0" max="1000000" value="1" /></td>
                                <td>
                                    <input type="text" id="txtxun" class="inwei" name="CL_name" list="select_codes" value="${item.FM_ji}"/>
                                    <datalist id="select_codes" class="form-control" style="display:none">
                                        @foreach (var item in ViewBag.JIliang as List<Freht>)
                                            {
                                                <option>@item.Fre_beizhu</option>
                                            }
                                    </datalist>
                                </td>
                                <td id="B_BMCL"><input type="text" class="inwei" id="leibie" value="${item.FM_yj}" /></td>
                                <td id="B_YCL"><input type="text" class="inwei" id="leib_ji" value="${item.FM_ej}" /></td>
                                <td id="B_MS"><input type="number" class="inwei" name="empYong" value="1" /></td>
                                <td>
                                    <input type="text" id="txtxuns" class="inwei" name="CL_Gong" list="select_Lei" value="${item.FM_Zhuang}"/>
                                    <datalist id="select_Lei" class="form-control" style="display:none">
                                        <option>--@Resource.String63--</option>
                                        <option value="外购">@Resource.String130</option>
                                        <option value="自制">@Resource.String131</option>
                                    </datalist>
                                </td>
                                <td style="display:none">1</td>
                                <td style="display:none"></td>
                            </tr>`);
                                $('#WLTable').append($tr);
                                if (i == jm) {
                                    $("#btnBaocun").trigger("click")
                                }
                            })

                        },
                        error: function () {
                            alert("系统错误!");
                        }
                    })
                } else {
                    alert("至少选中一行！")
                }
            })
            //获取物料信息
            function getMaterialInformation(e) {
                var temp = e.parent().parent().children()
                var temp2 = temp.eq(3).children().val()//料号
                $.ajax({
                    url: "/Application/Application",
                    type: "POST",
                    data: { "Name": temp2, "state": 16 },
                    success: function (sjik) {
                        console.log(sjik)
                        $.each(sjik, function (i, item) {
                            $("#amt_WLM").val(item.FM_name)
                            $("#amt_WLBM").val(item.FM_bai)
                            $("#cahns").val(item.FM_long)
                            $("#cahns1").val(item.FM_kuan)
                            $("#cahns2").val(item.FM_gao)
                            $("#amt_BMCL").val(item.FM_bmcl)
                            $("#amt_YCL").val(item.FM_ycl)
                            $("#amt_MS").val(item.FM_ms)
                            $("#Biaomian").val(item.FM_zx)
                            $("#amt_NYL").val(item.FM_nyl)
                            $("#amt_DW").val(item.FM_ji)
                            $("#shuxinss").val(item.FM_Zhuang)
                            $("input[name='Biaomian']").val(item.FM_Jieti)
                            var Sone = item.FM_yj;
                            Sone = Sone == "纸质" || Sone == "纸制品" ? "1" : Sone == "木质" || Sone == "木制品" ? "2" : Sone == "塑料" || Sone == "塑料制品" ? "3" : Sone == "金属制品" ? "4" : Sone == "布" ? "5" : Sone == "胶粘制品" ? "6" : Sone == "其他" ? "7" : Sone == "套件" ? "8" : Sone;
                            $("#dl_wl").val(Sone)
                            $.ajax({
                                url: '/Admin/Purchasing_Authority',
                                type: 'GET',
                                data: { "id": Sone, "state": 4 },
                                success: function (data) {
                                    console.log(data)
                                    $("#leibei_x option").remove()
                                    $.each(data, function (i, item) {
                                        $("#leibei_x").append($(`<option value="${item.zl_name}">${item.zl_name}</option>`))
                                    })
                                    $("#leibei_x").val(item.FM_ej)
                                },
                                error: function () {
                                    alert('Request Error2');
                                    Getquanx()
                                }
                            })
                        })
                    },
                    error: function () {
                        alert("erroer");
                    },
                })
                $("#addwl_main").css({ "display": "block" })
               /* $("#amt_WLM").attr({ "readonly": "readonly" })*/

            }

            //保存项目备注
            //$(function () {
            //    //日志写入数据库
            //    $(document).on("click", "#RZ_tjrz", function () {
            //        var now = new Date($.now());
            //        var year = (now.getFullYear()).toString();
            //        var month = (now.getMonth() + 1).toString();
            //        var date = (now.getDate()).toString();
            //        var hours = (now.getHours()).toString()
            //        var minutes = (now.getMinutes()).toString()

            //        //组合当前日期
            //        var sqrq = year + "/" + month + "/" + date + " " + hours + ":" + minutes
            //        var rzxx = {
            //            B_Bian: $("#txtdan").val(),
            //            B_BR: $('#Login_N').val(),
            //            B_Date: sqrq,
            //            B_bei: $('#RZ_xznr').val(),

            //        };
            //        console.log(rzxx)
            //        $.ajax({
            //            url: "/Contracts/AddLogs",
            //            type: "POST",
            //            data: rzxx,
            //            success: function (data) {
            //                alert(data)
            //                gettbz()
            //            },
            //            error: function (data) {
            //                alert("erroer");
            //            },
            //        })
            //    })
            //})
            $("#Quxiao").click(function () {
                $(".YCFile").hide()
            })
            $("#Tiao").click(function () {
                $("#JINDN").hide()
                $("#Yin").toggle()
            })
            $(document).on("change", "#SJ_HANG1", function () {
                changehangye2()
            })

            function changehangye2() {
                var id = $("#SJ_HANG1").val()
                $.ajax({
                    url: "/Application/Application",
                    type: "POST",
                    data: { "CL_ID": id, "state": 10 },
                    success: function (sjik) {
                        $("#SJ_HANG2 option").remove();
                        $("#SJ_HANG2").append($(`<option value="0" >--@Resource.String63--</option>`));
                        $.each(sjik, function (i, item) {
                            var $tr = $(`<option value="${item.isu_id}" >${item.isu_name}</option>`);
                            $("#SJ_HANG2").append($tr);
                        })
                        if ($("#hangye2").val()!="") {
                            $("#SJ_HANG2").val($("#hangye2").val())
                        }
                    },
                    error: function () {
                        alert("erroer");
                    },
                })
            }

            $(document).on("change", "#hangye1", function () {
                changehangye()
            })

            function changehangye() {
                var id = $("#hangye1").val()
                $.ajax({
                    url: "/Application/Application",
                    type: "POST",
                    data: { "CL_ID": id, "state": 10 },
                    success: function (sjik) {
                        $("#hangye2 option").remove();
                        $("#hangye2").append($(`<option value="0" >--@Resource.String63--</option>`));
                        $.each(sjik, function (i, item) {
                            var $tr = $(`<option value="${item.isu_id}" >${item.isu_name}</option>`);
                            $("#hangye2").append($tr);
                        })
                    },
                    error: function () {
                        alert("erroer");
                    },
                })
            }


            function Liaohao() {
                $.ajax({
                    url: '/Formations/FomShu',
                    type: 'POST',
                    data: { "steate": 1 },
                    success: function (e) {
                        var shu = Number(e) + 1;
                        var afi = "WL" + "000" + shu;
                        if (shu => 10) {
                            afi = "WL" + "00" + shu
                        }
                        if (shu => 100) {
                            afi = "WL" + "0" + shu
                        }
                        if (shu > 1000) {
                            afi = "WL" + shu
                        }
                        //写入随机申请单号
                        $("#amt_WLBM").val(afi)
                    },
                    error: function () {
                        alert("错误")
                    }
                })
            }
        })
        //获取备注信息
        function gettbz() {
            var kan = $("#txtdan").val();
            $.ajax({
                url: "/Application/Application",
                type: "POST",
                data: { "App_ban": kan, "state": 4 },
                success: function (sjik) {
                    $("#RZ_gwzr div").remove();
                    $.each(sjik, function (i, item) {
                        var $tr = $(`
                                     <div>
                                         <div>
                                             <span>${item.B_BR}</span><span>${item.B_Date}</span>
                                         </div>
                                         <div>
                                             ${item.B_bei}
                                         </div>
                                     </div>`);
                        $("#RZ_gwzr").append($tr);
                    })
                },
                error: function () {
                    alert("erroer");
                },
            })
        }
        //获取图纸信息
        Load_design_table()
        //获取图纸信息
        function Load_design_table() {
                $.ajax({
                    url: '/Application/Application',
                    type: 'POST',
                    data: { "state": 3, "App_ban": $('#txtdan').val() },
                    success: function (path) {
                        createFJ(path)
                    },
                    error: function () {
                        alert("系统错误!");
                    }
                })
            }
        function createFJ(fgggh) {
                $("#logfuj tr").remove();
                $("#div3__tb tr").remove();
                $("#div5_tb tr").remove();
                var ind1 = 1
                var ind2 = 1
                var temp=0
                $.each(fgggh, function (i, item) {
                    var x = item.De_dizhi
                    if (item.DE_lei == "图纸") {
                        if (item.DE_tuiLei == "驳回") {
                            var DE_tuiLeiDE="设计主管驳回"
                            var $tr = (`
                                <tr class="log_tr">
                                    <td style="display:none">${item.DE_id}</td>
                                    <td>${ind1}</td>
                                    <td>${item.DE_TZname}</td>
                                    <td>${item.bom_id}</td>
                                    <td>${item.De_shijian}</td>
                                    <td>${item.HD}</td>
                                    <td>${item.HX}</td>
                                    <td>${item.DE_bzpl}</td>
                                    <td>${item.DE_tzlb}</td>
                                    <td>${item.DE_BB}</td>
                                    <td>${item.De_ren}</td>
                                    <td>
                                        <input type="number" readonly="readonly" value="${item.DE_Slong}" style="width:60px;height:30px"/>
                                    </td>
                                    <td class="sjtzt"><a id="ckbhly_tz" href="#" >${DE_tuiLeiDE}</a></td>
                                    <td >${item.DZ_ShTIme}</td>
                                    <td >${item.DZ_Fnajm}</td>
                                    <td><a href="#" id="log_SC">删除</a>/<a href="#" id="log_SXSC">重新上传</a>/<a href="/Contracts/Download_file?path=${x}" id="log_SZ">下载</a></td>
                                </tr>`);
                            $("#div3__tb").append($tr);
                        }
                        else if (item.DE_tuiLei == "待审核") {
                            var DE_tuiLeiDE = "待设计主管审核"
                            var $tr = (`
                                <tr class="log_tr">
                                    <td style="display:none">${item.DE_id}</td>
                                    <td>${ind1}</td>
                                    <td>${item.DE_TZname}</td>
                                    <td>${item.bom_id}</td>
                                    <td>${item.De_shijian}</td>
                                    <td>${item.HD}</td>
                                    <td>${item.HX}</td>
                                    <td>${item.DE_bzpl}</td>
                                    <td>${item.DE_tzlb}</td>
                                    <td>${item.DE_BB}</td>
                                    <td>${item.De_ren}</td>
                                    <td>
                                        <input type="number" readonly="readonly" value="${item.DE_Slong}" style="width:60px;height:30px"/>
                                    </td>
                                    <td class="sjtzt">${DE_tuiLeiDE}</td>
                                    <td >${item.DZ_ShTIme}</td>
                                    <td >${item.DZ_Fnajm}</td>
                                    <td><a href="#" id="log_SC" class="bianjiann">删除</a>/<a href="#" id="log_SXSC" class="bianjiann">重新上传</a>/<a href="/Contracts/Download_file?path=${x}" id="log_SZ">下载</a></td>
                                </tr>`);
                            $("#div3__tb").append($tr);
                        }
                        else {
                            var DE_tuiLeiDE = "设计主管通过"
                            var $tr = (`

                                <tr class="log_tr">
                                    <td style="display:none">${item.DE_id}</td>
                                    <td>${ind1}</td>
                                    <td>${item.DE_TZname}</td>
                                    <td>${item.bom_id}</td>
                                    <td>${item.De_shijian}</td>
                                    <td>${item.HD}</td>
                                    <td>${item.HX}</td>
                                    <td>${item.DE_bzpl}</td>
                                    <td>${item.DE_tzlb}</td>
                                    <td>${item.DE_BB}</td>
                                    <td>${item.De_ren}</td>
                                    <td>
                                        <input type="number" readonly="readonly" value="${item.DE_Slong}" style="width:60px;height:30px"/>
                                    </td>
                                    <td class="sjtzt">${DE_tuiLeiDE}</td>
                                    <td >${item.DZ_ShTIme}</td>
                                    <td >${item.DZ_Fnajm}</td>
                                    <td><a href="#" id="log_SC">删除</a>/<a href="#" id="log_SXSC">重新上传</a>/<a href="/Contracts/Download_file?path=${x}" id="log_SZ">下载</a></td>
                                </tr>`);
                            $("#div3__tb").append($tr);
                        }
                        ind1++
                        temp += item.DE_Slong * 1
                    }
                    else {
                        var shundjian = ""
                        if ($("#Login_sf").text() == "销售助理" | $("#Login_sf").text() == "业务主管" | $("#Login_sf").text() == "业务发展部经理" | $("#Login_sf").text() == "客户经理" | $("#Login_N").text() == item.De_ren) {
                            shundjian = " | <span id='SferJ'>删除</span>"
                        }
                        var $tr = (`
                        <tr class="log_tr">
                            <td style="display:none">${item.DE_id}</td>
                            <td>${ind2}</td>
                            <td>${item.DE_TZname}</td>
                            <td>${item.De_shijian}</td>
                            <td>${item.De_ren}</td>
                            <td><a href="/Contracts/Download_file?path=${x}" id="log_SZ">@Resource.String582</a>${shundjian}</td>
                        </tr>`);
                        $("#logfuj").append($tr);
                        ind2++
                    }
                    if ($("#Login_zj").text() == "2" && item.DE_tuiLei=="待审核") {
                    var $tr =
                        (`
                            <tr class="log_tr">
                                <td style="display:none">${item.DE_id}</td>
                                <td>${i + 1}</td>
                                <td>${item.DE_TZname}</td>
                                <td>${item.bom_id}</td>
                                <td>${item.De_shijian}</td>
                                <td>${item.HD}</td>
                                <td>${item.HX}</td>
                                <td>${item.DE_bzpl}</td>
                                <td>${item.DE_tzlb}</td>
                                <td>${item.DE_BB}</td>
                                <td>${item.De_ren}</td>
                                <td style="display:none">${item.DE_bzw}</td>
                                <td>
                                    <input type="number"  value="${item.DE_Slong}" style="width:60px;height:30px"/>
                                </td>
                                <td class="WT_SHZT">${item.DE_tuiLei}</td>
                                <td class="WT_Up" style="color:red">修改</td>
                                <td><a href="#" class="Log_sh" id="change_time">@Resource.String575</a>/<a href="/Contracts/Download_file?path=${x}" id="log_SZ">@Resource.String582</a></td>
                                <td><a href="#" id="OFFkm">@Resource.String584</a>/<a href="#" id="log_back">@Resource.String583</a></td>
                                <td style="display:none">${item.DE_h1_id}</td>
                                <td style="display:none">${item.DE_h2_id}</td>
                            </tr>
                        `);
                        $("#div5_tb").append($tr);
                    }
                })
                $("#SJ_ZYS").text(temp)
            }
        function FUzher(a) {
            $.ajax({
                url: '/Application/Application',
                type: 'POST',
                data: { "state": 30 },
                success: function (path) {
                    if (path == "获取错误") {
                        alert(path)
                    } else {
                        $("#XMfzr option").remove()
                        $.each(path, function (i, item) {
                            var $op = $(`<option value="${item[0]}">${item[0]}</optino>`)
                            $("#XMfzr").append($op)
                        })
                    }
                    $("#XMfzr").val(a)
                },
                error: function () {
                    alert("系统错误!");
                }
            })
        }
        $(document).on("click", "#SferJ", function () {
            var id = $(this).parent().parent().children().eq(0).text()
            if (confirm("是否删除这条附件！！！！！")) {
                $.ajax({
                    url: '/Application/Application',
                    type: 'POST',
                    data: { "state": 31, "DE_id": id },
                    success: function (path) {
                        if (path == "0") {
                            alert("删除失败")
                        } else {
                            alert("删除成功")
                            Load_design_table()
                        }
                    },
                    error: function () {
                        alert("系统错误!");
                    }
                })
            }
        })
        //新增和删除物料行
        $(function () {
            //删除物料行
            $("#DELcheck").click(function () {
                if (confirm('确定要删除这些物料吗?')) {
                     RemoverTR()
                }
            })
            //点击修改时间
            $(document).on("click", "#change_time", function (e) {
                change_time($(e.target))
            })
            function change_time(e) {
                DE_id = e.parent().parent().children().first().text()//设计图id
                DE_Slong = e.parent().parent().children().eq(5).children().val()
                var BZJG = [];
                BZJG.push({
                    DE_id: DE_id,
                    DE_Slong: DE_Slong

                })
                console.log("共" + BZJG.length + "数据");
                console.log(BZJG);
                $.ajax({
                    url: "/Contracts/Modify_des_Slong",
                    type: 'POST',
                    data: JSON.stringify(BZJG),
                    contentType: "application/json;charset=utf-8",
                    dataType: "json",
                    success: function (text) {
                        alert(text)
                    },
                    error: function (text) {
                        alert("系统错误" + text);
                    }
                })
            }
            function RemoverTR() {
                var formation = [];
                $("input[class='XANZK']:checked").each(function (index, obj) {
                    console.log($(obj).parent().parent().children().eq(13).text())
                    var shunnn = $(obj).parent().parent().children().eq(13).text()
                    if (shunnn != "") {
                        formation.push({
                            FM_bai: shunnn,
                            FM_name: $("#txtdan").val(),
                        })
                    } else {
                        $(obj).parent().parent().remove()
                    }
                })
                console.log("共" + formation.length + "数据");
                console.log(formation);
                if (formation.length > 0) {
                    $.ajax({
                        url: "/Application/RemoveMaterial",
                        type: "POST",
                        data: JSON.stringify(formation),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (text) {
                            alert(text)
                            var check = $("input[class='XANZK']:checked").parent().parent().get()
                            $(check).remove();
                        },
                        error: function (text) {
                            alert("系统错误" + text);
                        }
                    })
                }
            }
        })
        $(document).on("click", "#btnWCXM", function (e) {
            efj($(e.target).text())
        })
        $(document).on("click", "#btnJSXM", function (e) {
            efj($(e.target).text())
        })
        $(document).on("click", ".WT_Up", function (e) {
            $("#DE_ID_1").text($(e.target).parent().children().eq(0).text())
            $("#show_shangc").css({ "display": "block" })
            $("#QUEding_SCOP").css({ "display": "block" })
            $("#QUEding_SC").css({ "display": "none" })
            $("#SJ_HANG1").val($(e.target).parent().children().eq(17).text())
            $("#SJ_HANG1").trigger("change")
            $("#SCWJ_SJ").parent().css({ "display": "none" })
            $("#TZ_BB").attr("readonly", "readonly")
            $("#TZ_BZPL").val($(e.target).parent().children().eq(7).text())
            $("#TZ_TZLB").val($(e.target).parent().children().eq(8).text())
            $("#SJ_bzwmc").val($(e.target).parent().children().eq(11).text())
            $("#TZ_BB").val($(e.target).parent().children().eq(9).text())
            $("#SLong").val($(e.target).parent().children().eq(12).children().val())
            setTimeout(function (){ $("#SJ_HANG2").val($(e.target).parent().children().eq(17).children().val()) },500)
        })

        function efj(e) {
            var id = $("#txtdan").val();
            var index = e
            var zhuang = ""
            var now = new Date($.now());
            var year = (now.getFullYear()).toString();
            var month = (now.getMonth() + 1).toString();
            var date = (now.getDate()).toString();
            var time = year + "/" + month + "/" + date
            var num = $("#Login_N").text()
            if (index == "完成" || index=="通过") {
                zhuang = "5"
            }
            else if (index=="结束") {
                zhuang="-99"
            }
            console.log(zhuang)
            var BZJG = [];
            BZJG.push({
                D_Ton: id,
                D_zhuang: zhuang,
                D_CD: time,
                D_TCA: num
            })
            console.log("共" + BZJG.length + "数据");
            console.log(BZJG);
            $.ajax({
                url: "/Contracts/Modify_des_zhuang2",
                type: 'POST',
                data: JSON.stringify(BZJG),
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function (text) {
                    if (text == "项目继续") {
                        window.location.href = "/Detailed/Boms?names=" + id;
                    }
                    else if (text == "项目结束") {
                        alert(text)
                        window.location.href = "/Contracts/Inspect_Contracts";
                    }
                    else if (text == "项目完成") {
                        alert(text)
                        window.location.href = "/Contracts/Inspect_Contracts";
                    }
                },
                error: function (text) {
                    alert("系统错误" + text);
                }
            })
        }

        var kan = $("#txtname").val();
        function BOMINsjj() {
            $.ajax({
                url: "/Application/Application",
                type: "POST",
                data: { "App_ban": kan, "state": 9 },
                success: function (sjik) {
                    createBom(sjik);
                },
                error: function () {
                    alert("erroer");
                },
            })
        }
        function createBom(sjik) {
            $("#WLTable tr").remove();
            $.each(sjik, function (i, item) {
                var $tr = $(`<tr>
                                <td><input type="checkbox"class="XANZK"/></td>
                                <td><input type="text" class="inwei" value="${item.BOM2_chen}" readonly></td>
                                <td><input type="text" class="inwei"value="${item.BOM2_liao}"readonly></td>
                                <td><input type="text" class="inwei"value="${item.BOM2_wuLiu}"readonly></td>
                                <td><input type="text" class="inwei"value="${item.BOM2_Guige}"readonly></td>
                                <td><input type="text" class="inwei"value="${item.BOM2_Nian}"readonly></td>
                                <td><input type="text" class="inwei"value="${item.BOM2_fenzi}"readonly></td>
                                <td><input type="text" class="inwei"value="${item.BOM2_Sone}"readonly></td>
                                <td><input type="text" class="inwei"value="${item.BOM2_ST}"readonly></td>
                                <td><input type="text" class="inwei"value="${item.BOM2_Yong}"readonly></td>
                                <td><input type="text" class="inwei"value="${item.BOM2_Lei}"readonly></td>
                                <td style="display:none">0</td>
                                <td style="display:none">${item.BOM2_id}</td>
                            </tr>`);
                $("#WLTable").append($tr);
            })
        }
        function get_BOM_H() {
            $.ajax({
                url: '/Application/Application',
                type: 'POST',
                data: { "App_ban": $('#txtdan').val(), "state": 12 },
                success: function (e) {
                    console.log(e)
                    queewn()
                    GF_BOM(e)
                },
                error: function () {
                    alert("系统错误！");
                }
            })
        }
        function queewn() {
            var JJ = $("#LIunji").text()
            if (JJ != "") {
                $("#div1 input,select").attr("readonly", "readonly")
                $(".Yinchande").hide()
                $("#divv_1").css({ "display": "block" })
                $("#lisul").text("")
                $("#lisul").prev().text("修改物料二级类型")
            }
        }
        function GF_BOM(data) {
    $('#WLTable tr').remove()
    $.each(data, function (i, item) {
        //var KKOL = ""
        var temp7 = item.BOM2_Sone;
        var index = ""
        index = temp7 == "1" ? "纸质" : temp7 == "2" ? "木质" : temp7 == "3" ? "塑料" : temp7 == "4" ? "金属制品" : temp7 == "5" ? "布" : temp7 == "6" ? "胶粘制品" : temp7 == "7" ? "其他" : temp7 == "8" ? "套件" : temp7;
        var $tr =$(`<tr id="WLtr">
                    <td style="width:20px;"><input type="checkbox" class="XANZK"/></td>
                    <td><lable id="labes">${item.BOM2_chen}</lable></td>
                    <td><a id="app_CkWl" href="#">物料信息</a></td>
                    <td ><input type="text" class="inwei" name="empLiao" id="empLiao" value="${item.BOM2_liao}" /></td>
                    <td ><input type="text" class="inwei" name="empName" id="empName" value="${item.BOM2_wuLiu}" /></td>
                    <td ><input type="text" class="inwei" name="empMiao" id="empMiao" value="${item.BOM2_Guige}" /></td>
                    <td ><input type="number" class="inwei" name="empNian" min="0" max="1000000" value="${item.BOM2_Nian}" /></td>
                    <td>
                        <input type="text" id="txtxun" class="inwei" name="CL_name" list="select_codes" value="${item.BOM2_fenzi}" />
                        <datalist id="select_codes" class="form-control" style="display:none" >
                            @foreach (var item in ViewBag.JIliang as List<Freht>)
                                        {
                                        <option>@item.Fre_beizhu</option>
                                        }
                        </datalist>
                    </td>
                    <td >
                    <input type="text" class="inwei" id="leibie" value="${index}" />
                    </td>
                    <td id="jisndd">
                        <input type="text" class="inwei" id="leib_ji" value="${item.BOM2_ST}" />
                    </td>
                    <td id="B_MS"><input type="number" class="inwei" name="empYong" value="${item.BOM2_Yong}"/></td>
                    <td>
                        <input type="text" id="txtxuns" class="inwei" name="CL_Gong" list="select_Lei"  value="${item.BOM2_Lei}"/>
                        <datalist id="select_Lei" class="form-control" style="display:none" >
                            <option>--@Resource.String63--</option>
                            <option value="外购">@Resource.String130</option>
                            <option value="自制">@Resource.String131</option>
                        </datalist>
                    </td>
                    <td style="display:none">1</td>
                    <td style="display:none">${item.BOM2_id}</td>
                </tr>`
            );
        $('#WLTable').append($tr);
    })
}
        //生成单号和发起时间
        $(function () {
            randomGeneration()
            function randomGeneration() {
                var id = $("#appp_id").text()
                var JJ = $("#LIunji").text()
                if (id == 0) {
                    //产生随机数
                    var x = 1000000
                    var y = 9999999
                    var num = parseInt(Math.random() * (x - y + 1) + y)
                    var now = new Date($.now())
                    //获取当前年月日
                    var year = (now.getFullYear()).toString();
                    var month = (now.getMonth() + 1).toString();
                    var date = (now.getDate()).toString();
                    var qishi_time = year + month + date
                    var qishi_time2 = year + "-" + month + "-" + date
                    var afi = "SQ" + qishi_time + num
                    //写入随机申请单号
                    $("#txtdan").val(afi)
                    $("#WT_rwdh").text(afi)
                    //写入当年月日
                    $("#txtqishi").val(qishi_time2)
                    $("#WT_sqrq").text(qishi_time2)
                    var sjin=""
                    FUzher(sjin)
                }
                else {
                    $.ajax({
                        url: '/Application/Application',
                        type: 'POST',
                        data: { "id": id, "state": 11 },
                        success: function (e) {
                            var BUZHO=""
                            $.each(e, function (i, item) {
                                $("#txtname").val(item.App_Kehu)
                                $('#txtdan').val(item.AP_bian)
                                $('#txtqishi').val(item.App_qishi)
                                $('#txtjeishu').val(item.App_JTime)
                                $('#txtxiangmu').val(item.APP_name)
                                $('#txtzhongduan').val(item.APP_Zhong)
                                $('#txtsho').val(item.App_dizhi)
                                $('#txtjuli').val(item.App_ju)
                                $('#txtxun').val(item.App_mu)
                                $('#txtfu').val(item.App_sho)
                                $('#txtleix').val(item.App_lei)
                                $('#Selse').val(item.APP_she)
                                $("#txtbaozuang").val(item.App_baozhuangwu)
                                $("#hangye1").val(item.App_hangda)
                                $("#Faqiren").text(item.AP_ren)
                                $("#txtPrice").val(item.App_Jz)
                                FUzher(item.App_fzr)
                                hangye20(item.App_hangxiao)
                                if (item.APP_she != "N") {
                                    $("#divweituo").show()
                                }
                                if (Math.abs(item.App_bu) > 1) {
                                    $("#divv_8").hide()
                                    $("#divv_4").hide()
                                }
                            })
                            getContracts()
                            get_BOM_H()
                            //BOMINsjj()
                            Load_design_table()
                            gettbz()
                            shinfdko()
                        },
                        error: function () {
                            alert("系统错误！");
                        }
                    })
                }
                queewn()
                if ($("#Login_bm").text() == "设计") {
                    $("#shshj").css({ "display": "none" })
                    //$("#queding").css({ "display": "none" })
                    if ($("#Login_zj").text() == "2") {
                        $("#divSP_FP").css({ "display": "block" })
                        $("#divv_4").css({ "display": "block" })
                        $("#divv_5").css({ "display": "block" })
                        $("#divv_1").css({ "display": "none" })
                        $("#divv_2").css({ "display": "none" })
                        $("#divv_09").css({ "display": "block" })
                        $("#divv_6").css({ "display": "block" })
                        $("#divv_10").css({ "display": "block" })
                        $.ajax({
                            url: '/Contracts/Inspect_Contracts',
                            type: 'GET',
                            data: { "state": 3, "D_ID": $("#Login_name").text(), "id": id },
                            success: function (zc) {
                                if (zc.length==0) {
                                    $("#divv_6").css({ "display": "none" })
                                }else{
                                    $.each(zc, function (i, obj) {
                                        if (obj.SJ_ZT == "完成") {
                                            $("#divv_6").css({ "display": "none" })
                                        } else {
                                            $("#divv_5").css({ "display": "none" })
                                        }
                                    })
                                }

                            },
                            error: function () {
                                alert('Request Error');
                            }
                        })
                    }
                    else {
                        $("#divSP_FP").css({ "display": "none" })
                        $("#divv_4").css({ "display": "none" })
                        $("#divv_5").css({ "display": "none" })
                        $("#divv_1").css({ "display": "none" })
                        $("#divv_2").css({ "display": "none" })
                        $("#divv_6").css({ "display": "block" })
                        $("#divv_09").css({ "display": "block" })
                        $("#WT_dj,#WT_rwdlx").attr("disabled", "disabled");
                        $.ajax({
                            url: '/Contracts/Inspect_Contracts',
                            type: 'GET',
                            data: { "state": 3, "D_ID": $("#Login_name").text(), "D_Ton": $("#txtdan").val() },
                            success: function (zc) {
                                $.each(zc, function (i, obj) {
                                    if (obj.SJ_ZT == "完成") {
                                        $("#show_shgcdiv").css({ "display": "none" })
                                        $("#bianjiann").css({ "display": "none" })
                                        $("#divv_6").css({ "display": "none" })

                                    }
                                })
                            },
                            error: function () {
                                alert('Request Error');
                            }
                        })
                    }
                }
                else if ($("#Login_bm").text() == "业务" || $("#Login_sf").text() == "业务发展部经理") {
                    $("#divSP_FP").css({ "display": "none" })
                    $("#divv_4").css({ "display": "none" })
                    $("#divv_5").css({ "display": "none" })
                    $("#divv_1").css({ "display": "block" })
                    $("#divv_2").css({ "display": "block" })
                    if ($("#Login_sf").text() == "客户经理" || $("#Login_sf").text() == "销售助理") {
                        if ($("#appp_Sjzt").text() == "设计委托") {
                            $("#divv_7").css({ "display": "block" })
                            $("#divv_8").css({ "display": "block" })
                        }
                    }
                    else {
                        $.ajax({
                            url: "/Application/Application",
                            type: "POST",
                            data: { "id": id, "state": 18 },
                            success: function (sjik) {
                                if ($("#appp_Sjzt").text() == "设计委托" && sjik == "显示") {
                                    //$("#divv_7").css({ "display": "block" })
                                    $("#divv_8").css({ "display": "block" })
                                }
                            },
                            error: function () {
                                alert("erroer");
                            },
                        })
                    }

                }
                if (JJ != "") {
                    $("#div1 input,select").attr("readonly", "readonly")
                    $(".Yinchande").hide()
                    $("#divv_1").css({ "display": "block" })
                    $("#lisul").text("")
                    $("#lisul").prev().text("修改物料二级类型")
                }
            }


            function hangye20(ws) {
                var id = $("#hangye1").val()
                $.ajax({
                    url: "/Application/Application",
                    type: "POST",
                    data: { "CL_ID": id, "state": 10 },
                    success: function (sjik) {
                        $("#hangye2 option").remove();
                        $("#hangye2").append($(`<option value="0" >--@Resource.String63--</option>`));
                        $.each(sjik, function (i, item) {
                            var $tr = $(`<option value="${item.isu_id}" >${item.isu_name}</option>`);
                            $("#hangye2").append($tr);
                        })
                        $("#hangye2").val(ws);
                    },
                    error: function () {
                        alert("erroer");
                    },
                })
            }
            /*function shinfdko() {
                var DTon = $('#txtdan').val()
                $.ajax({
                    url: "/Application/Application",
                    type: 'GET',
                    data: { "state": 14, "App_ban": DTon },
                    success: function (data) {
                        $.each(data, function (i, item) {
                            var $tr=$(` <tr style="background-color:white;text-align:center">
                                            <td>
                                               ${item.DE_nae}
                                            </td>
                                            <td>${item.DE_bumeng}</td>
                                            <td>${item.DE_phone}</td>
                                            <td><input  type="text" value="${item.SJ_BZ}" readonly/></td>
                                            <td></td>
                                        </tr>`)
                            $("#WT_JDR_Tb").append($tr)
                        })
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }*/
            $("#btnreste").click(function () {
                var namd = $("#appp_Sjzt").text()
                if (namd == "设计委托" || namd == "设计委托2") {
                    window.location.href = "/Contracts/Inspect_Contracts"
                }
                else {
                    window.location.href = "/Application/Requisition_form"
                }

            })
            function getContracts() {
                var DTon = $('#txtdan').val()
                $.ajax({
                    url: "/Contracts/Design_order",
                    type: 'GET',
                    data: { "state": 1, "DTon": DTon },
                    success: function (data) {
                        Show_old_data(data);
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }

            //写入旧数据的方法
            function Show_old_data(data) {
                $.each(data, function (i, item) {
                    $("#WT_sqrq").text(item.D_Applic)
                    $("#WT_yqrq").val(item.D_reDate)
                    $("#WT_rwdh").text(item.D_Ton)
                    $("#WT_sqr").val(item.D_App)
                    $("#WT_sqshr").val(item.D_AppRevi)
                    $("#WT_khmc").val(item.D_CN)
                    $("#WT_cpmc").val(item.D_PN)
                    $("#WT_dj").val(item.D_LV)
                    $("#WT_sjhs").val(item.D_DT)
                    $('#WT_cpzl').val(item.D_PW)
                    $('#WT_ddsm').val(item.D_SI)
                    $('#WT_qtxx').val(item.D_OI)
                    $('#WT_qtyq').val(item.D_OR)
                    $('#WT_csyq').val(item.D_SR)
                    $('#WT_jdr').val(item.D_REC)
                    $('#WT_jdshy').val(item.D_AR)
                    $('#WT_wcrq').text(item.D_CD)
                    $('#WT_wcshy').val(item.D_TCA)
                    $('#WT_xmjz').val(item.D_price)
                    $("#WT_bz").text(item.D_zhuang)
                    $('#WT_rwdlx').val(item.D_take)
                    $('#Derowid').text(item.D_id)
                    $('#ZhuathhskM').text(item.D_zhuang)
                    console.log($("WT_bz").text())
                    //设计类别
                    if (item.D_DE != null) {
                        var D_DE = item.D_DE.split(" ")
                        D_DE.pop()
                        console.log(D_DE)
                        $("input[name='WT_sjlb']").each(function (i, a) {
                            if (D_DE.includes(a.value) == true) {
                                a.checked = true
                            }
                        })
                    }
                    //任务单类型
                    if (item.D_take != null) {
                        var D_DE = item.D_take.split(" ")
                        D_DE.pop()
                        console.log(D_DE)
                        $("input[name='WT_sjlb']").each(function (i, a) {
                            if (D_DE.includes(a.value) == true) {
                                a.checked = true
                            }
                        })
                    }
                    if (item.D_MOF != null) {
                        //运输方式
                        var D_MOF = item.D_MOF.split(" ")
                        D_MOF.pop()
                        console.log(D_MOF)
                        $("input[name='WT_ysfs']").each(function (i, b) {
                            if (D_MOF.includes(b.value) == true) {
                                b.checked = true
                            }
                        })
                    }
                    if (item.D_PT != null) {
                        //包装方式
                        var D_PT = item.D_PT.split(" ")
                        D_PT.pop()
                        console.log(D_PT)
                        $("input[name='WT_bzlx']").each(function (i, c) {
                            if (D_PT.includes(c.value) == true) {
                                c.checked = true
                            }
                        })
                    }
                    if (item.D_PR != null) {
                        //防护要求
                        var D_PR = item.D_PR.split(" ")
                        D_PR.pop()
                        console.log(D_PR)
                        $("input[name='WT_fhyq']").each(function (i, d) {
                            if (D_PR.includes(d.value) == true) {
                                d.checked = true
                            }
                        })
                    }
                    if (item.D_PA != null) {
                        //项目附件
                        var D_PA = item.D_PA.split(" ")
                        D_PA.pop()
                        console.log(D_PA)
                        $("input[name='WT_xmbzfjxx']").each(function (i, e) {
                            if (D_PA.includes(e.value) == true) {
                                e.checked = true
                            }
                        })
                    }
                    console.log(item.D_zhuang)
                    if (item.D_zhuang == "3") {
                        //,#divv_4
                        $("#WT_JDR_TJ,#TJIAO_JDRF").css({"display":"none"})
                    }
                    var jsi = $("#JNDKO").text()
                    if (jsi == "未确认") {
                        $("#divv_2").css({ "display": "block" })
                    }
                    if (item.D_zhuang > 3 && $("#Login_bm").text() == "业务") {
                        $("#divv_1,#divv_2").css({ "display": "none" })
                    }
                    if (item.D_zhuang == 4 && $("#Login_bm").text() == "业务") {
                        $("#divv_4").css({ "display": "block" })
                    }
                    if (item.D_zhuang == 5 && $("#Login_bm").text() == "业务" && $("#Selse").val() == "S") {
                        $("#divv_4").css({ "display": "block" })
                    } else if (item.D_zhuang == 5 && $("#Login_bm").text() == "业务"){
                        $("#divv_4").css({ "display": "none" })
                    }
                })
            }
        })
        //点击切换基础信息，备注信息，图纸沟通
        $(function () {
            $("#divjibeng").click(function (e) {
                $("#div1").css({ "display": "block" });
                $("#div2").css({ "display": "none" });
                $("#div3").css({ "display": "none" });
                $("#div4").css({ "display": "none" });
                $("#div5").css({ "display": "none" });
                $("#APP_WLSQ").css({ "display": "block" })
                $("#APP_sjwt_bz").css({ "display": "none" })
            })
            $("#divbeizhu").click(function (e) {
                $("#div2").css({ "display": "block" });
                $("#div1").css({ "display": "none" });
                $("#div3").css({ "display": "none" });
                $("#div4").css({ "display": "none" });
                $("#div5").css({ "display": "none" });
                $("#APP_WLSQ").css({ "display": "none" })
                $("#APP_sjwt_bz").css({ "display": "none" })
            })
            $("#divtuzhi").click(function (e) {
                $("#div3").css({ "display": "block" });
                $("#div1").css({ "display": "none" });
                $("#div2").css({ "display": "none" });
                $("#div4").css({ "display": "none" });
                $("#div5").css({ "display": "none" });
                $("#APP_WLSQ").css({ "display": "none" })
                $("#APP_sjwt_bz").css({ "display": "none" })
            })
            $(document).on("click", "#divweituo", function () {
                $("#div3").css({ "display": "none" });
                $("#div1").css({ "display": "none" });
                $("#div2").css({ "display": "none" });
                $("#div4").css({ "display": "block" });
                $("#div5").css({ "display": "none" });
                $("#APP_WLSQ").css({ "display": "none" })
                $("#APP_sjwt_bz").css({ "display": "block" })
                var SF = $("#Login_bm").text()
                if (SF !="设计") {
                    $("#WT_sqr").val($("#Login_N").text())
                    $("#WT_cpmc").val($("#txtxiangmu").val())
                    $("#WT_khmc").val($("#txtname").val())
                    $("#WT_rwdh").text($("#txtdan").val())
                    $("#WT_sqrq").text($("#txtqishi").val())
                    $("#WT_xmjz").val($("#txtPrice").val())
                }
            })
            $(document).on("click", "#divSP_FP", function () {
                $("#div1").css({ "display": "none" });
                $("#div2").css({ "display": "none" });
                $("#div3").css({ "display": "none" });
                $("#div4").css({ "display": "none" });
                $("#div5").css({ "display": "block" });
                $("#APP_WLSQ").css({ "display": "none" })
                $("#APP_sjwt_bz").css({ "display": "none" })
            })
            $(document).on("click", ".qh_div", function (e) {
                $(e.target).parent().children().css({ "background-color": "#ededed" })
                $(e.target).css({ "background-color": "white" })
            })
        })

        //点击按钮把申请单信息写入数据库
        $(function () {
            $(document).on("click", ".btn_app_tj", function (e) {
                var JJ = $("#LIunji").text()
                if ($("#LIunji").text() == "") {
                    if ($(e.target).val() == "提交") {
                        if (confirm("请确定单据信息是否正确，附件上传是否齐全，物料类型是否正确")) {
                            var index = ""
                            $("#WLTable tr").each(function (i, temp) {
                                if ($("input[name='CL_Gong']", temp).val() != "自制" && $("input[name='CL_Gong']", temp).val() != "外购") {
                                    index += $("input[name='empName'] ", temp).val() + " "
                                }
                            })
                            if (index == "") {
                                addAPPlication($(e.target).val())
                            }
                            else {
                                alert("以下物料:" + index + "请选择自制或外购")
                            }
                        }
                    }
                    else if ($(e.target).val() == "保存") {
                        addAPPlication($(e.target).val())
                    }
                } else {
                    if (confirm("请确定单据信息是否正确，是否存在未维修改信息")) {
                        var index = ""
                        $("#WLTable tr").each(function (i, temp) {
                            if ($("input[name='CL_Gong']", temp).val() != "自制" && $("input[name='CL_Gong']", temp).val() != "外购") {
                                index += $("input[name='empName'] ", temp).val() + " "
                            }
                        })
                        if (index == "") {
                            var sjin = $("#txtdan").val()
                            window.location.href = JJ + "?names=" + sjin;
                        }
                        else {
                            alert("以下物料:" + index+"请选择自制或外购")
                        }

                    }
                }
            })

            function siundh() {

                var mbr = $("#WJ_tjr").text()
                var name = $("#Login_N").text()
                var bian = $("#txtdan").val()
                var BZJG = [];

                var now = new Date($.now());
                var year = (now.getFullYear()).toString();
                var month = (now.getMonth() + 1).toString();
                var date = (now.getDate()).toString();
                var time = year + "/" + month + "/" + date
                BZJG.push({
                    Fr_fl: "报价发起",//待处理模块
                    De_tiji: "销售提交的设计需求",//待处理内容
                    Cl_juli: "设计主管",//接收人
                    Nd_jiage: name,//发起人
                    Fr_zhuang: "待处理",//装态
                    Fr_time: time,
                    Fr_bian: bian
                })
                console.log("共" + BZJG.length + "数据");
                console.log(BZJG);
                $.ajax({
                    url: "/Contracts/Addfr",
                    type: 'POST',
                    data: JSON.stringify(BZJG),
                    contentType: "application/json;charset=utf-8",
                    dataType: "json",
                    success: function (text) {
                        alert("已提交至设计主管")
                    },
                    error: function (text) {
                        alert("系统错误" + text);
                    }
                })
            }
            var duandian=""
            function addAPPlication(e) {
                var hang = $("#WLTable tr").length;
                var zhand = $("#Selse option:selected").val() == "S" ? "3" : "8";//3--纯设计，7--设计+报价（步骤为一）
                var buzho = e == "保存"?"1": $("#Selse option:selected").val() == "N" ? "2" : "1";//保存为 1 提交进行判断
                var App_bei = e
                var application = {
                    App_Kehu: $("#txtname").val(),
                    AP_ren: $("#Login_N").text(),
                    Ap_bian: $('#txtdan').val(),
                    App_qishi: $('#txtqishi').val(),
                    App_JTime: $('#txtjeishu').val(),
                    App_name: $('#txtxiangmu').val(),
                    App_Zhong: $('#txtzhongduan').val(),
                    App_dizhi: $('#txtsho').val(),
                    App_ju: $('#txtjuli').val(),
                    App_mu: $('#txtxun').val(),
                    App_sho: $('#txtfu').val(),
                    App_lei: $('#txtleix').val(),
                    App_bu: buzho,
                    App_fenL: 0,
                    APP_she: $('#Selse option:selected').val(),
                    App_miao: $("#BIanhao").text(),
                    App_BanB: 1,
                    App_zhand: zhand,
                    App_baozhuangwu: $("#txtbaozuang").val(),
                    App_hangda: $("#hangye1").val(),
                    App_hangxiao: $("#hangye2").val(),
                    App_bei: App_bei,
                    App_Jz: $("#txtPrice").val(),
                    App_fzr: $("#XMfzr").val(),
                    App_xmzt: "OPEN Opportunities",
                    APP_Zhong:"X"
                };

                console.log(application)
                if (e == "提交") {
                    var TIjiaozhuangt=2
                    if (application.App_KeHu == "--请选择--") {
                        return alert("@Resource.String144！000");
                    }
                    else if (application.App_name == "") {
                        alert("@Resource.String145！");
                    }
                    else if (application.App_JTime == "") {
                        alert("@Resource.String57！");
                    }
                    else if (application.App_dizhi == "") {
                        alert("@Resource.String147！");
                    }
                    else if (application.App_fzr == null) {
                        alert("项目负责人不能为空")
                    }
                    else if (application.App_Jz == "") {
                        alert("项目价值不能为空")
                    }
                    else  if (parseInt(application.App_ju) <= 0) {
                        alert("@Resource.String149！");
                    } else if ( application.App_hangda =="--@Resource.String48--") {
                        alert("行业大类不能为空！");
                    } else if ( application.App_hangxiao=="--@Resource.String63--") {
                        alert("行业小类不能为空！");
                    } else if (application.App_baozhuangwu == "") {
                        alert("包装物名称不能为空！");
                    }
                    else if (application.App_lei == "--请选择--") {
                        alert("@Resource.String150！");
                    }
                    else if ($("#WT_qtxx").val() == null && application.APP_she!="N") {
                        alert("其他信息不能为空")
                    }
                    else if ($("#WT_qtyq").val() == null && application.APP_she != "N") {
                        alert("其他要求不能为空")
                    }
                    else if ($("#WT_csyq").val() == null && application.APP_she != "N") {
                        alert("测试要求不能为空")
                    }
                    else if (hang < 1) {
                        alert("单据物料未添加，请先添加物料在进行提交！！！")
                    }
                    else {
                        var box1_1 = ""
                        var box2_1 = ""
                        var box3_1 = ""
                        var box4_1 = ""
                        var box5_1 = ""
                        var box1 = $("#WT_sjlb input[type=checkbox]:checked").serializeArray()
                        var box2 = $("input[name='WT_ysfs']:checked").serializeArray()
                        var box3 = $("input[name='WT_bzlx']:checked").serializeArray()
                        var box4 = $("input[name='WT_fhyq']:checked").serializeArray()
                        var box5 = $("input[name='WT_xmbzfjxx']:checked").serializeArray()
                        $.each(box1, function (i, item) {
                            box1_1 += item.value + " "
                        })
                        $.each(box2, function (i, item) {
                            box2_1 += item.value + " "
                        })
                        $.each(box3, function (i, item) {
                            box3_1 += item.value + " "
                        })
                        $.each(box4, function (i, item) {
                            box4_1 += item.value + " "
                        })
                        $.each(box5, function (i, item) {
                            box5_1 += item.value + " "
                        })
                        var indexxx = 0;
                        console.log($('#WT_cpzl').val())
                        if ($('#WT_cpzl').val() == "") {
                            $('#WT_cpzl').css({ "border-color": "red" })
                            indexxx++
                        }
                        else {
                            $('#WT_cpzl').css({ "border-color": "black" })
                        }

                        if ($('#WT_ddsm').val() == "") {
                            indexxx++
                            $('#WT_ddsm').css({ "border-color": "red" })
                        }
                        else {
                            $('#WT_ddsm').css({ "border-color": "black" })
                        }

                        if ($('#WT_qtxx').val() == "") {
                            indexxx++
                            $('#WT_qtxx').css({ "border-color": "red" })
                        }
                        else {
                            $('#WT_qtxx').css({ "border-color": "black" })
                        }

                        if (box2_1 == "") {
                            indexxx++
                            $('#WT_ysfs').css({ "border": "1px solid red" })
                        }
                        else {
                            $('#WT_fhyq').css({ "border": "0px solid red" })
                        }

                        if ($('#WT_csyq').val() == "") {
                            indexxx++
                            $('#WT_csyq').css({ "border-color": "red" })
                        }
                        else {
                            $('#WT_csyq').css({ "border-color": "black" })
                        }

                        if (box3_1 == "") {
                            indexxx++
                            $('#WT_bzlx').css({ "border": "1px solid red" })
                        }
                        else {
                            $('#WT_bzlx').css({ "border": "0px solid red" })
                        }

                        if ($('#WT_qtyq').val() == "") {

                            $('#WT_qtyq').css({ "border-color": "red" })
                            indexxx++
                        }
                        else {
                            $('#WT_qtyq').css({ "border-color": "black" })
                        }

                        if (box4_1 == "") {
                            $('#WT_fhyq').css({ "border": "1px solid red" })
                            indexxx++
                        }
                        else {
                            $('#WT_fhyq').css({ "border": "0px solid red" })
                        }
                        if (application.APP_she != "N") {
                            if (indexxx == 0) {
                                $.ajax({
                                    url: "/Application/AddApplication",
                                    type: "POST",
                                    data: application,
                                    success: function (data) {
                                        console.log(data)
                                        if (application.APP_she != "N") {
                                            append_Contracts(TIjiaozhuangt, e)
                                            Tboms();
                                            siundh();
                                           window.location.href = "/Application/Requisition_form";
                                        } else {
                                            Tboms();
                                           window.location.href = "/Application/Requisition_form";
                                        }
                                    },
                                    error: function () {
                                        alert("erroer");
                                    },
                                })
                            }
                            else {
                                alert("设计委托，红框标注为必填")
                            }
                        }
                        else {
                            $.ajax({
                                url: "/Application/AddApplication",
                                type: "POST",
                                data: application,
                                success: function (data) {
                                    Tboms();
                                    window.location.href = "/Application/Requisition_form";
                                },
                                error: function () {
                                    alert("erroer");
                                },
                            })
                        }
                    }
                }
                else {
                    var temp=1
                    if (hang < 1) {
                        $.ajax({
                            url: "/Application/AddApplication",
                            type: "POST",
                            data: application,
                            success: function (data) {
                                console.log(data)
                                if (application.APP_she != "N") {
                                    append_Contracts(temp,e)
                                }
                            },
                            error: function () {
                                alert("erroer");
                            },
                        })
                    }
                    else {
                        $.ajax({
                            url: "/Application/AddApplication",
                            type: "POST",
                            data: application,
                            success: function (data) {
                                console.log(data)
                                if (application.APP_she != "N") {
                                    append_Contracts(temp,e)
                                    Tboms();
                                } else {
                                    Tboms();
                                }
                            },
                            error: function () {
                                alert("erroer");
                            },
                        })
                    }
                }
            }
            function Tboms() {
                var BOMinise = [];
                var shen = $("#txtdan").val();
                var hu = 0;
                $("#WLTable tr").each(function (index, obj) {
                    if ($("#labes", obj).html() == "Leve0") {
                        hu = hu + 1 * 1000;
                    }
                    if ($("#labes", obj).html() == "leve1") {
                        hu = hu +"-A";
                    }

                    var Sone = $("#leibie", obj).val() == null ? $("#leibie", obj).val() : $("#leibie", obj).val();
                    var Sted = $("#leib_ji", obj).val() == null ? $("#leib_ji", obj).val() : $("#leib_ji", obj).val();
                    Sone = Sone == "纸质" || Sone == "纸制品" ? "1" : Sone == "木质" || Sone == "木制品" ? "2" : Sone == "塑料" || Sone == "塑料制品" ? "3" : Sone == "金属制品" ? "4" : Sone == "布" ? "5" : Sone == "胶粘制品" ? "6" : Sone == "其他" ? "7" : Sone == "套件"?"8": Sone;
                    BOMinise.push({
                        BOM2_chen: $("#labes", obj).html(),//层级
                        BOM2_wuLiu: $("input[name='empName'] ", obj).val(),//物料信息
                        BOM2_liao: $("input[name='empLiao'] ", obj).val(),//料号
                        BOM2_Guige: $("input[name='empMiao'] ", obj).val(),//产品规格
                        BOM2_Nian: $("input[name='empNian'] ", obj).val(),//年用量
                        BOM2_fenzi: $("input[name='CL_name']", obj).val(), //计量单位
                        BOM2_Yong: $("input[name='empYong'] ", obj).val(),//Bom 用量
                        BOM2_Lei: $("input[name='CL_Gong']", obj).val(),/*自制或采购*/
                        BOM2_bian: shen,
                        BOM2_Ctime: $("#txtqishi").val(),
                        BOM2_BQing: hu,
                        BOM2_Zhuang: 1,
                        BOM2_Sone: Sone,
                        BOM2_ST: Sted
                        //预留添加标识
                    })
                })
                console.log("共" + BOMinise.length + "数据");
                console.log(BOMinise);
                //--
                //发出请求
                $.ajax({
                    url: "/Application/AddAppli",
                    type: "POST",
                    data: JSON.stringify(BOMinise),
                    contentType: "application/json;charset=utf-8",
                    dataType: "json",
                    success: function (text) {
                        if (text >0) {
                            alert("添加成功")
                        } else {
                            alert("添加失败" + text.msg);
                        }
                    },
                    error: function (text) {
                        alert("系统错误" + text);
                    }
                })
            }
            $("#btnUpdate").click(function () {
                if ($("#Login_sf").text() == "设计主管" || $("#Login_sf").text() == "设计员" || $("#Login_sf").text() == "设计经理") {
                    if ($("#WT_rwdlx").val() != "null" && $("#WT_dj").val() != "null") {
                        $("#WT_rwdlx").css({ "border-color": "snow" })
                        $("#WT_dj").css({ "border-color": "snow" })
                        var shunf = $("#ZhuathhskM").text()
                        var sjin = "提交"
                        append_Contracts(shunf, sjin)
                    } else {
                        alert("等级和任务单类型必填！")
                        $("#WT_rwdlx").css({ "border-color": "red" })
                        $("#WT_dj").css({ "border-color": "red" })
                    }
                }
            })

            function append_Contracts(zhuang,Tishi) {
                var jdr = ""
                $(".WT_JDR_a2").each(function (i, item) {
                    var index = $(item).val()
                    var temp = index.split(" ")
                    var lastElement = temp[1];
                    jdr += lastElement + " "
                })
                var box1_1 = ""
                var box2_1 = ""
                var box3_1 = ""
                var box4_1 = ""
                var box5_1 = ""
                var box1 = $("#WT_sjlb input[type=checkbox]:checked").serializeArray()
                var box2 = $("input[name='WT_ysfs']:checked").serializeArray()
                var box3 = $("input[name='WT_bzlx']:checked").serializeArray()
                var box4 = $("input[name='WT_fhyq']:checked").serializeArray()
                var box5 = $("input[name='WT_xmbzfjxx']:checked").serializeArray()
                $.each(box1, function (i, item) {
                    box1_1 += item.value + " "
                })
                $.each(box2, function (i, item) {
                    box2_1 += item.value + " "
                })
                $.each(box3, function (i, item) {
                    box3_1 += item.value + " "
                })
                $.each(box4, function (i, item) {
                    box4_1 += item.value + " "
                })
                $.each(box5, function (i, item) {
                    box5_1 += item.value + " "
                })
                var bcxx = {
                    D_Applic: $('#WT_sqrq').text(),
                    D_reDate: $('#WT_yqrq').val(),
                    D_price: $('#WT_xmjz').val(),
                    D_Ton: $('#WT_rwdh').text(),
                    D_App: $('#WT_sqr').val(),
                    D_AppRevi: $('#WT_sqshr').val(),
                    D_CN: $('#WT_khmc').val(),
                    D_PN: $('#WT_cpmc').val(),
                    D_take: $('#WT_rwdlx option:selected').val(),
                    D_DE: box1_1,
                    D_LV: $('#WT_dj').val(),
                    D_DT: $('#WT_sjhs ').val(),
                    D_PW: $('#WT_cpzl').val(),
                    D_SI: $('#WT_ddsm').val(),
                    D_OI: $('#WT_qtxx').val(),
                    D_MOF: box2_1,
                    D_PT: box3_1,
                    D_PR: box4_1,
                    D_OR: $('#WT_qtyq').val(),
                    D_SR: $('#WT_csyq').val(),
                    D_PA: box5_1,
                    D_REC: jdr,
                    D_AR: $('#WT_jdshy').val(),
                    D_CD: $('#WT_wcrq').text(),
                    D_TCA: $('#WT_wcshy').val(),
                    D_zhuang: zhuang,
                    D_id: $("#Derowid").text()
                };
                console.log(bcxx)
                if (Tishi != "提交") {
                    $.ajax({
                        url: "/Contracts/Temporary_storage",
                        type: "POST",
                        data: bcxx,
                        success: function (data) {
                            alert("设计委托" + data)
                        },
                        error: function (data) {
                            alert("erroer");
                        },
                    })
                } else {
                    if ($("#Login_bm").text() == "业务") {
                        if (bcxx.D_PW == "" || bcxx.D_SI == "" || bcxx.D_OI == "" || bcxx.D_MOF == "" || bcxx.D_PT == "" || bcxx.D_OR == "" || bcxx.D_SR == "") {
                            alert("红框内为必填项")
                            duandian = "1"
                        }
                        else {
                            $.ajax({
                                url: "/Contracts/Temporary_storage",
                                type: "POST",
                                data: bcxx,
                                success: function (data) {
                                    alert("设计委托" +data)
                                },
                                error: function (data) {
                                    alert("erroer");
                                },
                            })
                        }
                    }
                    else {
                        if (bcxx.D_take == "" || bcxx.D_DE == "") {
                            alert("等级和类型不能为空！")
                        } else {
                            $.ajax({
                                url: "/Contracts/Temporary_storage",
                                type: "POST",
                                data: bcxx,
                                success: function (data) {
                                    alert("设计委托" + data)
                                },
                                error: function (data) {
                                    alert("erroer");
                                },
                            })
                        }
                    }
                }
            }

        })

        function jisndd(snMk) {
            var $lishu7 = $(`<ul id="lisul" class="row col-sm-5">
                                        <li class="lisu">1</li>&rArr;
                                        <li class="lisu"></li>&rArr;
                                        <li class="lisu"></li>&rArr;
                                        <li class="lisu"></li>&rArr;
                                        <li class="lisu"></li>&rArr;
                                        <li class="lisu"></li>&rArr;
                                        <li class="lisu"></li>
                                    </ul>`)
            var $lishu3 = $(`<ul id="lisul" class="row col-sm-5">
                                        <li class="lisu">1</li>&rArr;
                                        <li class="lisu"></li>&rArr;
                                        <li class="lisu"></li>
                                    </ul>`)
            if (snMk == "纯设计") {
                $("#lisul ").replaceWith($lishu3)
            } else {
                $("#lisul").replaceWith($lishu7)
            }
        }
        $(document).on("change", "#txtleix", function () {
            var snedMk = $(this).val()
            jisndd(snedMk)
        })
        $("#yin").css({ "display": "block" });
        $("#Bomz").addClass("disabled");
        //客户名输入事件
        $(function () {
            $("#txtname").blur(function () {
                var shun = $("#txtname").val();
                var Zhu = $("#SelZZ").val()
                $.ajax({
                    url: '/Application/Application',
                    type: 'POST',
                    data: { "Name": shun, "Shunqi": Zhu,"state": 1 },
                    success: function (e) {
                        createSel(e);
                    },
                    error: function () {
                        alert("系统错误！");
                    }
                })
            })
            function createSel(e) {
                $("#seleect_codeDE option").remove();
                var Zhu = $("#SelZZ").val()
                $.each(e, function (i, item) {
                    var $tr = (`<option value="${item.CL_name}">`);
                    var sho = item.CL_sho;
                    var juli = item.CL_ju;
                    $("#seleect_codeDE").append($tr);
                    $("#txtjuli").val(juli);
                    $("#hangye1").val(item.CL_shuo);
                    $("#BIanhao").text(item.CL_bian)
                    $("#txtfu").val(item.CL_lian)
                    $("#txtzhongduan").val(item.CL_ZDKH)
                    if (i == (e.length - 1)) {
                        $.ajax({
                            url: '/Application/Application',
                            type: 'POST',
                            data: { "Name": item.CL_name, "Shunqi": Zhu, "state": 35 },
                            success: function (F) {
                                console.log(F)
                                $("#SH_DZ option").remove();
                                $("#SH_DZ").append(`<option>--@Resource.String63--</option>`);
                                $.each(F, function (k, HJ) {
                                    if (HJ[0] != "" && HJ[0]!=" ") {
                                        $("#SH_DZ").append(`<option>${HJ[0]}</option>`);
                                    }
                                })
                            },
                            error: function () {
                                alert("系统错误！");
                            }
                        })
                    }
                })
                $("#hangye1").trigger('change')
            }
        })
        //绑定物料库
        $(document).on("keyup", "#empLiao", function (x) {
            var shun = $(x.target).val();
            var Zhu = $("#SelZZ").val()
            $.ajax({
                url: '/Application/Application',
                type: 'POST',
                data: { "Named": shun, "Shunqi": Zhu, "state": 2 },
                success: function (e) {
                    console.log(e)
                    createSel(e);
                },
                error: function () {
                    alert("系统错误！");
                }
            })
            function createSel(e) {
                $("#seleect_codes option").remove();
                var gui;
                var leix;
                var liao;
                var ji;
                var Sone ="";
                var SDET ="";
                var Nyleds ="";
                $.each(e, function (i, item) {
                    $("#seleect_codes").append(`<option value="${item.FM_bai}">${item.FM_name}</option>`);
                    liao = item.FM_name;
                    leix = item.FM_Zhuang
                    ji = item.FM_ji
                    gui = item.FM_gg
                    Sone = item.FM_yj
                    SDET = item.FM_ej
                    Nyleds = item.FM_nyl
                })
                $(x.target).parent().next().children().first().val(liao)
                $(x.target).parent().next().next().children().first().val(gui)
                $(x.target).parent().next().next().next().next().children().first().val(ji)
                $(x.target).parent().parent().children().eq(6).children().first().val(Nyleds)
                $(x.target).parent().parent().children().eq(11).children().first().val(leix)
                $(x.target).parent().parent().children().eq(8).children().first().val(Sone)
                $(x.target).parent().parent().children().eq(9).children().first().val(SDET)
            }
        })
        //点击上传打开文件+复制行
        $(function () {
            $("#ShangC").click(function () {
                $(".YCFile").toggle()
            })
            $("#TIjaio").click(function () {
                var fileUpload = $('#SHanngcF')[0];
                if (fileUpload.files.length > 0) {
                    var formData = new FormData();
                    formData.append('file', fileUpload.files[0]);
                    $.ajax({
                        url: '/Material/ExcelFilePath',
                        type: 'POST',
                        data: formData,
                        processData: false,		//用于对data参数进行序列化处理 这里必须false
                        contentType: false,
                        success: function (fgggh) {
                            if (fgggh.length == 0) {
                                alert("该文件已打开，请关闭后重试！")
                            } else {
                                if (fgggh == "0") {
                                    alert("有物料未选择层级！请补全信息再提交");
                                } else {
                                    CreateBom(fgggh)
                                    $(".YCFile").hide()
                                }
                            }
                        },
                        error: function (xhr) {
                            alert("系统错误" + xhr);
                        }
                    })
                } else {
                    alert('请选择要上传的文件！');
                }
            })

            function CreateBom(fgggh) {
                console.log(fgggh)
                $("#WLTable tr").remove();
                $.each(fgggh, function (i, item) {
                    //var KKOL = ""
                    var Sone = item.BOM2_Sone;
                    var GUIG = item.FM_long + "*" + item.FM_kuan + "*" + item.FM_gao
                    var $tr =$(`<tr id="WLtr">
                               <td style="width:20px;"><input type="checkbox" class="XANZK"/></td>
                               <td><lable id="labes">${item.BOM2_chen}</lable></td>
                               <td><a id="app_CkWl" href="#">物料信息</a></td>
                               <td ><input type="text" class="inwei" name="empLiao" id="empLiao" value="${item.BOM2_liao}" /></td>
                               <td ><input type="text" class="inwei" name="empName" id="empName" value="${item.BOM2_wuLiu}" /></td>
                               <td ><input type="text" class="inwei" name="empMiao" id="empMiao" value="${GUIG}" /></td>
                               <td ><input type="number" class="inwei" name="empNian" min="0" max="1000000" value="${item.BOM2_Nian}" /></td>
                               <td>
                                   <input type="text" id="txtxun" class="inwei" name="CL_name" list="select_codes" value="${item.BOM2_fenzi}" />
                                   <datalist id="select_codes" class="form-control" style="display:none" >
                                        @foreach (var item in ViewBag.JIliang as List<Freht>)
                                                   {
                                                    <option>@item.Fre_beizhu</option>
                                                   }
                                   </datalist>
                               </td>
                               <td >
                                <input type="text" class="inwei" id="leibie" min="0" max="1000000" value="${Sone}" />
                               </td>
                               <td id="jisndd">
                                   <input type="text" class="inwei" id='leib_ji' min="0" max="1000000" value="${item.BOM2_ST}" />
                               </td>
                               <td id="B_MS"><input type="number" class="inwei" name="empYong" value="${item.BOM2_Yong}" /></td>
                               <td>
                                   <input type="text" id="txtxuns" class="inwei" name="CL_Gong" list="select_Lei"  value="${item.BOM2_Lei}"/>
                                   <datalist id="select_Lei" class="form-control" style="display:none" >
                                       <option>--@Resource.String63--</option>
                                       <option value="外购">@Resource.String130</option>
                                       <option value="自制">@Resource.String131</option>
                                   </datalist>
                               </td>
                               <td style="display:none">1</td>
                               <td style="display:none"></td>
                           </tr>`
                        );
                    $('#WLTable').append($tr);
                })
            }
        })
        function shinfdko() {
            var DTon = $('#txtdan').val()
            $.ajax({
                url: "/Application/Application",
                type: 'GET',
                data: { "state": 14, "App_ban": DTon },
                success: function (data) {
                    $.each(data, function (i, item) {
                        var shun = item.SJ_JL == null || item.SJ_JL == "0" || item.SJ_JL == "" ? "初次分配" : "第" + item.SJ_JL + "次再分配";
                        var $tr = $(` <tr style="background-color:white;text-align:center">
                                                <td>
                                                   ${item.DE_nae}
                                                </td>
                                                <td>${item.DE_bumeng}</td>
                                                <td>${item.DE_phone}</td>
                                                <td><input  type="text" value="${item.SJ_BZ}" readonly/></td>
                                                <td>${shun}</td>
                                                <td></td>
                                            </tr>`)
                        $("#WT_JDR_Tb").append($tr)
                    })
                },
                error: function () {
                    alert('Request Error');
                }
            })
        }
        //设计主管分配人员和审核
        $(function () {
            $(document).on("click", "#WT_JDR_TJ", function (e) {
                receiver($(e.target))
            })
            $(document).on("click", "#TJIAO_JDRF", function () {
                if ($("#WT_rwdlx").val() != "null" && $("#WT_dj").val() != "null") {
                    $("#WT_rwdlx").css({ "border-color": "snow" })
                    $("#WT_dj").css({ "border-color": "snow" })
                    if (confirm("人员分配只能分配一次请谨慎选择,若使用未分配的账号继续上传会跳过不处理")) {
                        SJ_BEIZ()
                    }
                } else {
                    alert("等级和任务单类型必填！")
                    $("#WT_rwdlx").css({"border-color":"red"})
                    $("#WT_dj").css({"border-color":"red"})
                }
            })
            //通过设计图
            $(document).on("click", "#WT_pass", function (e) {
                Through_drawing()
            })
            //打开
            $(document).on("click", "#OFFkm", function (e) {
               var JNKM= $(e.target).parent().parent().children().first().text()
                $("#JINFHH").text(JNKM)
                $("#TZsj").show()
            })
            //隐藏
            $(document).on("click", ".NOKM", function (e) {
                $("#TZsj").hide()
                $("#JINFHH").text("")
            })
            //点击驳回设计图
            $(document).on("click", "#WT_qdbh", function () {
                Rejected_plan()
                $("#WT_dh_mb").css({ "display": "none" })
            })

            //完成设计委托
            $(document).on("click", "#btnWANC", function () {
                if ($("#WT_rwdlx").val() != "null" && $("#WT_dj").val() != "null") {
                    $("#WT_rwdlx").css({ "border-color": "snow" })
                    $("#WT_dj").css({ "border-color": "snow" })
                    if (confirm("是否完成此项目")) {
                        complete_plan()
                    }
                } else {
                    alert("等级和任务单类型必填！")
                    $("#WT_rwdlx").css({ "border-color": "red" })
                    $("#WT_dj").css({ "border-color": "red" })
                }
            })

            //点击打开驳回面板驳回到业务
            $(document).on("click", "#btnBOHUI", function (e) {
                $("#WT_dh_mb2").css({ "display": "block" })
                var num = $("#Login_N").text()
                $("#WT_dhr2").text(num)
            })

            //点击关闭驳回面板
            $(document).on("click", "#WT_qxbh2", function (e) {
                $("#WT_dh_mb2").css({ "display": "none" })
                $("#WT_dhly2").val("")
                $("#WT_dhr2").text("")
            })

            //点击驳回到业务 根据身份进行判断
            $(document).on("click", "#WT_qdbh2", function (e) {
                $("#WT_dh_mb2").css({ "display": "none" })
                var shen = $("#Login_sf").text()
                if (shen == "设计员") {
                    append_Contracts20()
                } else if (shen == "设计主管" || shen == "设计经理") {
                    var zhuang = $("#WT_SJWt").val()
                    append_Contracts2(zhuang)
                } else if ($("#Login_bm").text() =="业务") {
                    append_Contr()
                }
            })
            //设计完成业务判断是否通过
            function append_Contr() {
                var name = $("#Login_N").text()
                var BZJG = [];
                var now = new Date($.now());
                var year = (now.getFullYear()).toString();
                var month = (now.getMonth() + 1).toString();
                var date = (now.getDate()).toString();
                var time = year + "/" + month + "/" + date
                var bian = $("#txtdan").val()
                BZJG.push({
                    Fr_fl: "设计委托",//待处理模块
                    De_tiji: "业务员有异议",//待处理内容
                    Cl_juli: "设计主管",//接收人
                    Nd_jiage: name,//发起人
                    Fr_zhuang: "待处理",//装态
                    Fr_time: time,
                    Fr_bian: bian
                })
                console.log("共" + BZJG.length + "数据");
                console.log(BZJG);
                var bcxx = {
                    D_Ton: $('#WT_rwdh').text(),
                    D_dhly: $("#WT_dhly2").val(),
                    D_dhr: $("#WT_dhr2").text()
                };
                $.ajax({
                    url: "/Application/Bohuus",
                    type: 'POST',
                    data: { "shunnf": $("#txtdan").val(), "dsres": bcxx },
                    success: function (text) {
                        if (text == "1") {
                            alert("单据没有设计！")
                        } else if (text == "3") {
                            alert("驳回失败！")
                        } else {
                            $.ajax({
                                url: "/Contracts/Addfr",
                                type: 'POST',
                                data: JSON.stringify(BZJG),
                                contentType: "application/json;charset=utf-8",
                                dataType: "json",
                                success: function (text) {
                                    alert("已返回对应的发起人账号")
                                    window.location.href = "/Contracts/Inspect_Contracts"
                                },
                                error: function (text) {
                                    alert("系统错误" + text);
                                }
                            })
                        }
                    },
                    error: function (text) {
                        alert("系统错误" + text);
                    }
                })
            }
            //设计驳回代办
            function Bohuis() {
                var mbr = $("#Faqiren").text()
                var name = $("#Login_N").text()
                var BZJG = [];
                var now = new Date($.now());
                var year = (now.getFullYear()).toString();
                var month = (now.getMonth() + 1).toString();
                var date = (now.getDate()).toString();
                var time = year + "/" + month + "/" + date
                var bian = $("#txtdan").val()
                BZJG.push({
                    Fr_fl: "设计委托",//待处理模块
                    De_tiji: "设计主管驳回单据",//待处理内容
                    Cl_juli: mbr,//接收人
                    Nd_jiage: name,//发起人
                    Fr_zhuang: "待处理",//装态
                    Fr_time: time,
                    Fr_bian: bian
                })
                console.log("共" + BZJG.length + "数据");
                console.log(BZJG);
                $.ajax({
                    url: "/Contracts/Addfr",
                    type: 'POST',
                    data: JSON.stringify(BZJG),
                    contentType: "application/json;charset=utf-8",
                    dataType: "json",
                    success: function (text) {
                        alert("已返回对应的发起人账号")
                    },
                    error: function (text) {
                        alert("系统错误" + text);
                    }
                })
            }
            //点击打开驳回面板
            $(document).on("click", "#log_back", function (e) {
                var id = $(e.target).parent().parent().children().first().text()
                var name = $(e.target).parent().parent().children().eq(4).text()
                $("#WJ_ID").text(id)
                $("#WT_dh_mb").css({ "display": "block" })
                var num = $("#Login_N").text()
                $("#WT_dhr").text(num)
                $("#WJ_tjr").text(name)
            })
            //点击关闭驳回面板
            $(document).on("click", "#WT_qxbh", function (e) {
                $("#WT_dh_mb").css({ "display": "none" })
                $("#WT_dhly").val("")
                $("#WT_dhr").text("")
                $("#WJ_ID").text("")
                $("#WJ_tjr").text("")
            })
            //完成上传任务
            $(document).on("click", "#WCSJ", function () {
                var temp1 = 0
                var temp2 = 0
                $("#div3__tb tr").each(function (i, item) {
                    var name = $(item).children().eq(10).text()
                    var zhuang = $(item).children().eq(12).text()

                    if (name == $("#Login_N").text()) {
                        temp1+=1
                    }
                    if (zhuang == "驳回") {
                        temp2+=1
                    }
                    console.log(temp1, temp2)
                })
                console.log(temp1, temp2)
                if (temp1 > 0 && temp2 == 0) {
                    if (confirm("是否上传全部文件，若未全部上传请点击取消，")) {
                        var BZJG = [];
                        BZJG.push({
                            SJR_id: $("#Login_name").text(),
                            SJ_Bian: $("#txtdan").val(),
                            SJ_ZT: "完成"
                        })
                        $.ajax({
                            url: "/Contracts/chaneSJBZ",
                            type: 'POST',
                            data: JSON.stringify(BZJG),
                            contentType: "application/json;charset=utf-8",
                            dataType: "json",
                            success: function (text) {
                                console.log(text)
                                BohuIIis()
                            },
                            error: function (text) {
                                alert("系统错误" + text);
                            }
                        })
                    }
                }
                else {
                    alert("还未上传附件或上传文件中有被驳回附件未处理")
                }
            })
            //设计驳回代办
            function BohuIIis() {
                var name = $("#Login_N").text()
                var BZJG = [];
                var now = new Date($.now());
                var year = (now.getFullYear()).toString();
                var month = (now.getMonth() + 1).toString();
                var date = (now.getDate()).toString();
                var time = year + "/" + month + "/" + date
                var bian = $("#txtdan").val()
                BZJG.push({
                    Fr_fl: "设计委托",//待处理模块
                    De_tiji: "设计员已上传图纸",//待处理内容
                    Cl_juli: "设计主管",//接收人
                    Nd_jiage: name,//发起人
                    Fr_zhuang: "待处理",//装态
                    Fr_time: time,
                    Fr_bian: bian
                })
                console.log("共" + BZJG.length + "数据");
                console.log(BZJG);
                $.ajax({
                    url: "/Contracts/Addfr",
                    type: 'POST',
                    data: JSON.stringify(BZJG),
                    contentType: "application/json;charset=utf-8",
                    dataType: "json",
                    success: function (text) {
                        alert("已提交设计主管处")
                        window.location.href = "/Contracts/Inspect_Contracts"
                    },
                    error: function (text) {
                        alert("系统错误" + text);
                    }
                })
            }
            //获取分配人
            function getFPR() {
                $.ajax({
                    url: '/Application/Application',
                    type: 'POST',
                    data: { "App_ban": $('#txtdan').text(), "state": 14 },
                    success: function (e) {
                        $("#WT_JDR_Tb tr").remove()
                        $.each(e, function (i, item) {
                            var $tr =
                                $(`
                                    <tr style="background-color:white;text-align:center">
                                        <td>
                                            <select id="WT_JDR_se" class="WT_JDR_a2" value="${item.Dengli.DE_nae}">
                                            <option value="">——@Resource.String711——</option>
                                                @foreach (var item in ViewBag.res as List <LanDBom.Models.Dengli>)
                                                 {
                                                    if (item.DE_bumeng==2)
                                                    {
                                                        <option value="@item.DE_phone+@item.DE_nae+@item.DE_ID">@item.DE_nae</option>
                                                    }

                                                 }
                                            </select>
                                        </td>
                                        <td>@Resource.String732</td>
                                        <td>${item.Dengli.DE_phone}</td>
                                        <td><input  type="text" value="${item.SJ_ZT}"/></td>
                                        <td><a href="#" id="WT_JDR_TJ">@Resource.String733</a></td>
                                    </tr>
                                `)
                            $("#WT_JDR_Tb").append($tr)
                        })
                    },
                    error: function () {
                        alert("系统错误！");
                    }
                })
            }

            function complete_plan() {
                var index = 0
                $(".sjtzt").each(function (i, item) {
                    if ($(item).text() != "设计主管通过") {
                        index += 1
                    }
                })
                if (index == 0) {
                    var RZ_bian = $("#txtdan").val()
                    var BZJG = [];
                    BZJG.push({
                        D_Ton: RZ_bian,
                        D_zhuang: "4"
                    })
                    console.log("共" + BZJG.length + "数据");
                    console.log(BZJG);
                    $.ajax({
                        url: "/Contracts/Modify_des_zhuang",
                        type: 'POST',
                        data: JSON.stringify(BZJG),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (text) {
                            alert(text)
                            var now = new Date($.now());
                            var year = (now.getFullYear()).toString();
                            var month = (now.getMonth() + 1).toString();
                            var date = (now.getDate()).toString();
                            var time = year + "/" + month + "/" + date
                            var bian = $("#txtdan").val()
                            var mbr = $("#Faqiren").text()
                            var name = $("#Login_N").text()
                            var BZJG = [];
                            BZJG.push({
                                Fr_fl: "设计委托",//待处理模块
                                De_tiji: "设计委托完成",//待处理内容
                                Cl_juli: mbr,//接收人
                                Nd_jiage: name,//发起人
                                Fr_zhuang: "待处理",//装态
                                Fr_time: time,
                                Fr_bian: bian
                            })
                            console.log("共" + BZJG.length + "数据");
                            console.log(BZJG);
                            $.ajax({
                                url: "/Contracts/Addfr",
                                type: 'POST',
                                data: JSON.stringify(BZJG),
                                contentType: "application/json;charset=utf-8",
                                dataType: "json",
                                success: function (text) {
                                    alert("已提交至单据发起人")
                                   Load_design_table()
                                    window.location.href = "/Contracts/Inspect_Contracts"
                                },
                                error: function (text) {
                                    alert("系统错误" + text);
                                }
                            })

                        },
                        error: function (text) {
                            alert("系统错误" + text);
                        }

                    })
                }
                else {
                    alert("还有" + index+"条设计图没有通过审核")
                }
            }

            function Rejected_plan() {
                var de_id = $("#WJ_ID").text()
                var bhly = $("#WT_dhly").val()
                var shr = $("#WT_dhr").text()
                if (bhly == "") {
                    alert("请输入驳回理由")
                }
                else {
                    var BZJG = [];
                    BZJG.push({
                        DE_id: de_id,
                        DE_JDR: shr,
                        DE_wenjain: bhly,
                        DE_tuiLei: "驳回"
                    })
                    console.log("共" + BZJG.length + "数据");
                    console.log(BZJG);
                    $.ajax({
                        url: "/Contracts/Modify_INF_zhuang",
                        type: 'POST',
                        data: JSON.stringify(BZJG),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (text) {
                            alert(text)
                            var mbr = $("#WJ_tjr").text()
                            var name = $("#Login_N").text()
                            var BZJG = [];
                            var now = new Date($.now());
                            var year = (now.getFullYear()).toString();
                            var month = (now.getMonth() + 1).toString();
                            var date = (now.getDate()).toString();
                            var time = year + "/" + month + "/" + date
                            var bian = $("#txtdan").val()

                            BZJG.push({
                                Fr_fl: "设计委托",//待处理模块
                                De_tiji: "设计图被驳回",//待处理内容
                                Cl_juli: mbr,//接收人
                                Nd_jiage: name,//发起人
                                Fr_zhuang: "待处理",//装态
                                Fr_time: time,
                                Fr_bian: bian

                            })
                            console.log("共" + BZJG.length + "数据");
                            console.log(BZJG);
                            $.ajax({
                                url: "/Contracts/Addfr",
                                type: 'POST',
                                data: JSON.stringify(BZJG),
                                contentType: "application/json;charset=utf-8",
                                dataType: "json",
                                success: function (text) {
                                    alert("已驳回到指定人员")

                                    $("#WT_dh_mb").css({ "display": "none" })
                                    Load_design_table()
                                },
                                error: function (text) {
                                    alert("系统错误" + text);
                                }
                            })
                        },
                        error: function (text) {
                            alert("系统错误" + text);
                        }
                    })
                }
            }

            //通过设计图
            function Through_drawing() {
                DE_id = $("#JINFHH").text()
                var num = $("#Login_N").text()
                if ($("#SHtime").val() != "" && $("#SHmiao").val() != "") {
                    var BZJG = [];
                    BZJG.push({
                        DE_id: DE_id,
                        DE_JDR: num,
                        DE_tuiLei: "通过",
                        DZ_ShTIme: $("#SHtime").val(),
                        DZ_Fnajm: $("#SHmiao").val()
                    })
                    console.log("共" + BZJG.length + "数据");
                    console.log(BZJG);
                    $.ajax({
                        url: "/Contracts/Modify_INF_zhuang2",
                        type: 'POST',
                        data: JSON.stringify(BZJG),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (text) {
                            $("#TZsj").hide()
                            $("#JINFHH").text("")
                            alert("审核通过")
                            Load_design_table()
                        },
                        error: function (text) {
                            alert("系统错误" + text);
                        }
                    })
                } else {
                    alert("审核时间和审核说明必填！")
                }
            }
            //分配接单人的方法
            function receiver(e) {
                var index = e.text()
                if (index == "添加") {
                    var $tr = $(`
                    <tr style="background-color:white;text-align:center">
                        <td>
                            <select id="WT_JDR_se" class="WT_JDR_a2">
                            <option value="">——@Resource.String711——</option>
                                @foreach (var item in ViewBag.res as List <LanDBom.Models.Dengli>)
                                 {
                                    if (item.DE_bumeng==2)
                                    {
                                        <option value="@item.DE_phone+@item.DE_nae+@item.DE_ID">@item.DE_nae</option>
                                    }

                                 }
                            </select>
                        </td>
                        <td>@Resource.String732</td>
                        <td></td>
                        <td><input  type="text"/></td>
                        <td id="SJJL" style="display:none"></td>
                        <td><a href="#" id="WT_JDR_TJ">@Resource.String733</a></td>
                    </tr>
                    `)
                    $("#WT_JDR_Tb").append($tr)
                }
                else {
                    e.parent().parent().remove()
                }
            }

            //提交接单人的方法
            function SJ_BEIZ() {
                var XMBZ = []
                var name = $("#Login_N").text()
                var BZJG = [];
                var Hnaghao = $("#WT_JDR_Tb tr").length
                var shu11 = 0;
                if (Hnaghao>0) {
                    $(".WT_JDR_a2").each(function (i, item) {
                        var index = $(item).val()
                        var temp = index.split("+")
                        var lastElement = temp[2];
                        var TwoElement = temp[1];
                        var bz = $(item).parent().next().next().next().children().first().val()
                        var now = new Date($.now());
                        var year = (now.getFullYear()).toString();
                        var month = (now.getMonth() + 1).toString();
                        var date = (now.getDate()).toString();
                        var time = year + "/" + month + "/" + date
                        var bian = $("#txtdan").val()
                        shu11++;
                        XMBZ.push({
                            SJR_id: lastElement,//接单人id
                            SJ_BZ: bz,//备注
                            SJ_Bian: $("#WT_rwdh").text(),//申请单号
                            SJ_ZT: "未确定",
                            SJ_JL: $("#SJJL").text()
                        })
                        BZJG.push({
                            Fr_fl: "设计委托",//待处理模块
                            De_tiji: "设计主管分配的设计任务",//待处理内容
                            Cl_juli: TwoElement,//接收人
                            Nd_jiage: name,//发起人
                            Fr_zhuang: "待处理",//装态
                            Fr_time: time,
                            Fr_bian: bian
                        })
                    })
                    console.log("共" + BZJG.length + "数据", "共" + XMBZ.length + "数据");
                    console.log(XMBZ);
                    console.log(BZJG);
                    if (shu11 > 0) {
                        if (XMBZ.length > 0) {
                            $.ajax({
                                url: "/Contracts/ADDSJBZ",
                                type: "POST",
                                data: JSON.stringify(XMBZ),
                                contentType: "application/json;charset=utf-8",
                                dataType: "json",
                                success: function (text) {
                                    $("#WT_JDR_TJ,#TJIAO_JDRF").css({ "display": "none" })
                                    changeDes_sqshr()
                                    getFPR()
                                    console.log(text)
                                    $.ajax({
                                        url: "/Contracts/Addfr",
                                        type: 'POST',
                                        data: JSON.stringify(BZJG),
                                        contentType: "application/json;charset=utf-8",
                                        dataType: "json",
                                        success: function (text) {
                                            alert("已返回对应的发起人账号")
                                            shinfdko()
                                        },
                                        error: function (text) {
                                            alert("系统错误" + text);
                                        }
                                    })
                                },
                                error: function (text) {
                                    alert("系统错误" + text);
                                }
                            })
                        }
                    } else {
                        var bian = $("#txtdan").val()
                        $.ajax({
                            url: "/Application/Application",
                            type: "POST",
                            data: { "Bianed": bian,"state":34},
                            success: function (text) {
                                if (text == "1") {
                                    alert("分配成功")
                                } else {
                                    alert("分配失败")
                                }
                            },
                            error: function (text) {
                                alert("系统错误" + text);
                            }
                        })
                    }
                }
            }
            function changeDes_sqshr() {
                var bcxx = {
                    D_Ton: $('#WT_rwdh').text(),
                    D_AppRevi: $("#Login_N").text(),
                };
                //---------------------------------------------------------------新增功能
                console.log(bcxx)
                $.ajax({
                    url: "/Contracts/Temporary_storage3",
                    type: "POST",
                    data: bcxx,
                    success: function (data) {

                    },
                    error: function (data) {
                        alert("erroer");
                    },
                })

            }

            function append_Contracts2(zhuang) {
                var bcxx = {
                    D_Ton: $('#WT_rwdh').text(),
                    D_dhly: $("#WT_dhly2").val(),
                    D_dhr: $("#WT_dhr2").text(),
                    D_zhuang: zhuang,
                };
                //---------------------------------------------------------------新增功能
                console.log(bcxx)
                $.ajax({
                    url: "/Contracts/Temporary_storage2",
                    type: "POST",
                    data: bcxx,
                    success: function (data) {
                        if (zhuang == 1) {
                            changeAPP_BOhui()
                        } else {
                            if (data == "1") {
                                alert("修改成功！")
                                window.location.href = "/Contracts/Inspect_Contracts"
                            } else { alert("修改失败！") }
                        }
                    },
                    error: function (data) {
                        alert("erroer");
                    },
                })
            }
            //设计员驳回值设计主管分配工作  人员不变可更改备注
            function append_Contracts20() {
                var shun=2
                var Ton = $("#txtdan").val()
                //---------------------------------------------------------------新增功能
                $.ajax({
                    url: "/Contracts/Append_Contracts20",
                    type: "POST",
                    data: { "Shun": shun, "Ton": Ton },
                    success: function (data) {
                        var name = $("#Login_N").text()
                        var BZJG = [];
                        var now = new Date($.now());
                        var year = (now.getFullYear()).toString();
                        var month = (now.getMonth() + 1).toString();
                        var date = (now.getDate()).toString();
                        var time = year + "/" + month + "/" + date
                        var bian = $("#txtdan").val()
                        BZJG.push({
                            Fr_fl: "设计委托",//待处理模块
                            De_tiji: "设计人员有异议",//待处理内容
                            Cl_juli: "设计主管",//接收人
                            Nd_jiage: name,//发起人
                            Fr_zhuang: "待处理",//装态
                            Fr_time: time,
                            Fr_bian: bian

                        })
                        console.log("共" + BZJG.length + "数据");
                        console.log(BZJG);
                        $.ajax({
                            url: "/Contracts/Addfr",
                            type: 'POST',
                            data: JSON.stringify(BZJG),
                            contentType: "application/json;charset=utf-8",
                            dataType: "json",
                            success: function (text) {
                                alert("已驳回到设计主管")
                                window.location.href = "/Contracts/Inspect_Contracts"
                            },
                            error: function (text) {
                                alert("系统错误" + text);
                            }
                        })
                    },
                    error: function (data) {
                        alert("erroer");
                    },
                })
            }
            function changeAPP_BOhui() {
                var bcxx = {
                    AP_bian: $('#txtdan').val(),
                    APP_liy: $("#WT_dhly2").val(),
                    APP_shr: $("#WT_dhr2").text(),
                    App_zhuang:"驳回"
                };
                //---------------------------------------------------------------新增功能
                console.log(bcxx)
                $.ajax({
                    url: "/Contracts/changeAPP_BOhui",
                    type: "POST",
                    data: bcxx,
                    success: function (data) {
                        Bohuis()
                    },
                    error: function (data) {
                        alert("erroer");
                    },
                })
            }
            $(document).on("click", "#ckbhly_tz", function (e) {
                $("#WT_dh_mb3").css({ "display": "block" })
                id = $(e.target).parent().parent().children().eq(0).text()
                $.ajax({
                    url: '/Application/Application',
                    type: 'POST',
                    data: { "state": 17, "id": id },
                    success: function (path) {
                        $.each(path, function (i, item) {
                            $("#WT_dhly3").val(item.DE_wenjain)
                            $("#WT_dhr3").text(item.DE_JDR)
                        })
                    },
                    error: function () {
                        alert("系统错误!");
                    }
                })
            })

            //点击关闭驳回面板
            $(document).on("click", "#WT_qxbh3", function (e) {
                $("#WT_dh_mb3").css({ "display": "none" })
                $("#WT_dhly3").val("")
                $("#WT_dhr3").text("")
            })

            //版本变更
            $(document).on("click", "#divv_10", function (e) {
                if (confirm("版本变更，单据回到业务填写数据")) {
                    var infW = prompt("请输入变更原因：", "");
                    if (infW != null) {
                        $.ajax({
                            url: '/Application/VersionC',
                            type: 'POST',
                            data: { "bian": $('#txtdan').val(), "ING": infW, "state": 1 },
                            success: function (path) {
                                alert(path)
                                if (path == "变更成功") {
                                    window.location.href ="/Contracts/Inspect_Contracts"
                                }
                            },
                            error: function () {
                                alert("系统错误!");
                            }
                        })
                    } else {
                        alert("未填写变更理由不可变更！")
                    }
                }
            })
        })

    </script>

}